Created
December 14, 2018 15:31
-
-
Save sajjadyousefnia/b6baabf3cba5cb095e3130b87d4e3306 to your computer and use it in GitHub Desktop.
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); | |
} | |
}); | |
} | |
public static final void lambdaInstance(@NotNull Function1 predicate) { | |
Intrinsics.checkParameterIsNotNull(predicate, "predicate"); | |
List list = CollectionsKt.listOf(new Integer[]{1, 2, 3}); | |
Iterable $receiver$iv$iv = (Iterable) list; | |
Collection destination$iv$iv$iv = (Collection) (new ArrayList()); | |
Iterator var6 = $receiver$iv$iv.iterator(); | |
while (var6.hasNext()) { | |
Object element$iv$iv$iv = var6.next(); | |
if ((Boolean) predicate.invoke(element$iv$iv$iv)) { | |
destination$iv$iv$iv.add(element$iv$iv$iv); | |
} | |
} | |
List newList = (List) destination$iv$iv$iv; | |
System.out.println(newList); | |
} | |
@NotNull | |
public static final List inlinedFilter(@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 var6 = $receiver$iv.iterator(); | |
while (var6.hasNext()) { | |
Object element$iv$iv = var6.next(); | |
if ((Boolean) predicate.invoke(element$iv$iv)) { | |
destination$iv$iv.add(element$iv$iv); | |
} | |
} | |
return (List) destination$iv$iv; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment