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
Error:(12, 34) Kotlin: Illegal usage of inline-parameter 'predicate' in 'public inline fun inlinedFilter(list: List<Int>, predicate: (Int) -> Boolean): List<Int> defined in functiontypes in file Inline.kt'. Add 'noinline' modifier to the parameter declaration |
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>{ | |
val function = predicate | |
return list.filter(predicate) | |
} |
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() { | |
List list$iv = CollectionsKt.listOf(new Integer[]{1, 2, 3}); | |
Iterable $receiver$iv$iv$iv = (Iterable)list$iv; | |
Collection destination$iv$iv$iv$iv = (Collection)(new ArrayList()); | |
Iterator var4 = $receiver$iv$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
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(); |