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
+5-2Lines changed: 5 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -141,13 +141,16 @@ class VariableShadowingUnitTest{
141
141
// in extension
142
142
assertEquals(15, numbers.sum())
143
143
144
-
fun List<Int>.sum(): Int { // shadowing built-in function sum()
144
+
fun List<Int>.sumByTwo(): Int { // shadowing built-in function sum()
145
145
var sum =0
146
146
this.forEach { sum += it *2 }
147
147
return sum
148
148
}
149
149
150
-
assertEquals(30, numbers.sum())
150
+
assertEquals(30, numbers.sumByTwo())
151
+
152
+
val doubledSum = numbers.sumOf { it *2 } // Modify lambda in sum
0 commit comments