You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core-kotlin-modules/core-kotlin-10/src/test/kotlin/com/baeldung/variableshadowing/VariableShadowingUnitTest.kt
+15-3Lines changed: 15 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -116,12 +116,24 @@ class VariableShadowingUnitTest{
116
116
val price =100// local variable
117
117
val discountRate =0.1
118
118
119
-
funapplyDiscount(price:Int): Double { // Nested function with parameter named 'price'
120
-
val updatedDiscountRate =0.2// Using a new variable name to avoid shadowing
121
-
return price * (1- updatedDiscountRate) // 'price' here refers to the parameter, not the outer variable
0 commit comments