Skip to content

Commit

Permalink
Replaced 'element % 42 == 0' predicate with 'element % 2 == 0'
Browse files Browse the repository at this point in the history
  to avoid confusion
  • Loading branch information
svtk committed Aug 17, 2017
1 parent e1f2c1c commit 3bcda37
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/i_introduction/_4_Lambdas/JavaCode4.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public boolean task4(Collection<Integer> collection) {
return Iterables.any(collection, new Predicate<Integer>() {
@Override
public boolean apply(Integer element) {
return element % 42 == 0;
return element % 2 == 0;
}
});
}
Expand Down
3 changes: 2 additions & 1 deletion src/i_introduction/_4_Lambdas/n04Lambdas.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ fun example() {
fun todoTask4(collection: Collection<Int>): Nothing = TODO(
"""
Task 4.
Rewrite 'JavaCode4.task4()' in Kotlin using lambdas.
Rewrite 'JavaCode4.task4()' in Kotlin using lambdas:
return true if the collection contains an even number.
You can find the appropriate function to call on 'Collection' by using code completion.
Don't use the class 'Iterables'.
""",
Expand Down
4 changes: 2 additions & 2 deletions test/i_introduction/_4_Lambdas/N04LambdasKtTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import org.junit.Test

class N04LambdasKtTest {
@Test fun contains() {
assertTrue(task4(listOf(1, 2, 3, 126, 555)))
assertTrue(task4(listOf(1, 2, 3)))
}

@Test fun notContains() {
assertFalse(task4(listOf(44)))
assertFalse(task4(listOf(1, 3, 5)))
}
}

0 comments on commit 3bcda37

Please sign in to comment.