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
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -78,6 +78,10 @@ class VariableShadowingUnitTest{
78
78
}
79
79
80
80
assertEquals(0, sum)
81
+
82
+
val lambda = { number :Int->
83
+
val number =1// Local variable in lambda
84
+
}
81
85
}
82
86
83
87
@Test
@@ -162,6 +166,12 @@ class VariableShadowingUnitTest{
162
166
163
167
assertEquals(0, sum)
164
168
169
+
numbers.forEach { number ->
170
+
sum += number // Directly access the current element in the loop
171
+
}
172
+
173
+
assertEquals(15, sum) // Assuming you want the sum of the original numbers
0 commit comments