This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static final boolean filterLessThanTwo(int input) { | |
| return input < 2; | |
| } | |
| public static final void lambdaInstanceTest() { | |
| lambdaInstance((Function1) new Function1<Integer, Boolean>() { | |
| @Override | |
| public Boolean invoke(Integer integer) { | |
| return filterLessThanTwo(integer); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| inline fun inlinedFilter(list : List<Int>, predicate : (Int) -> Boolean) : List<Int>{ | |
| return list.filter(predicate) | |
| } | |
| fun filterLessThanTwo(input: Int) = input < 2 | |
| fun lambdaInstance(predicate: (Int) -> Boolean) { | |
| val list = listOf(1,2,3) | |
| val newList = inlinedFilter(list, predicate) | |
| println(newList) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static final boolean filterLessThanTwo(int input) { | |
| return input < 2; | |
| } | |
| public static final void functionReferenceTest() { | |
| List list = CollectionsKt.listOf(new Integer[]{1, 2, 3}); | |
| Iterable $receiver$iv$iv = (Iterable)list; | |
| Collection destination$iv$iv$iv = (Collection)(new ArrayList()); | |
| Iterator var5 = $receiver$iv$iv.iterator(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| inline fun inlinedFilter(list : List<Int>, predicate : (Int) -> Boolean) : List<Int>{ | |
| return list.filter(predicate) | |
| } | |
| fun filterLessThanTwo(input: Int) = input < 2 | |
| fun functionReferenceTest() { | |
| val list = listOf(1,2,3) | |
| val newList = inlinedFilter(list, ::filterLessThanTwo) | |
| println(newList) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static final void lambdaInCallSiteTest() { | |
| List list = CollectionsKt.listOf(new Integer[]{1, 2, 3}); | |
| Iterable $receiver$iv$iv = (Iterable)list; | |
| Collection destination$iv$iv$iv = (Collection)(new ArrayList()); | |
| Iterator var5 = $receiver$iv$iv.iterator(); | |
| while(var5.hasNext()) { | |
| Object element$iv$iv$iv = var5.next(); | |
| int it = ((Number)element$iv$iv$iv).intValue(); | |
| if (it < 2) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| inline fun inlinedFilter(list : List<Int>, predicate : (Int) -> Boolean) : List<Int>{ | |
| return list.filter(predicate) | |
| } | |
| fun lambdaInCallSiteTest() { | |
| val list = listOf(1,2,3) | |
| val newList = inlinedFilter(list) {it < 2} | |
| println(newList) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @NotNull | |
| public static final List notInlinedFilter(@NotNull List list, @NotNull Function1 predicate) { | |
| Intrinsics.checkParameterIsNotNull(list, "list"); | |
| Intrinsics.checkParameterIsNotNull(predicate, "predicate"); | |
| Iterable $receiver$iv = (Iterable)list; | |
| Collection destination$iv$iv = (Collection)(new ArrayList()); | |
| Iterator var5 = $receiver$iv.iterator(); | |
| while(var5.hasNext()) { | |
| Object element$iv$iv = var5.next(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun notInlinedFilter(list: List<Int>, predicate: (Int) -> Boolean): List<Int> { | |
| return list.filter(predicate) | |
| } | |
| fun notInlinedTest() { | |
| val list = listOf(1, 2, 3) | |
| val newList = notInlinedFilter(list) { it < 2 } | |
| println(newList) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| inline fun <T> synchronized(lock: Lock, action: () -> T): T { | |
| lock.lock() | |
| try { | |
| return action() | |
| } | |
| finally { | |
| lock.unlock() | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NutritionFacts cocaCola = new NutritionFacts.Builder(240, 8) | |
| .calories(100).sodium(35).carbohydrate(27).build(); |