Skip to content

Instantly share code, notes, and snippets.

@sajjadyousefnia
Created December 14, 2018 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sajjadyousefnia/edf137f1f07adcbb253465104df4eab0 to your computer and use it in GitHub Desktop.
Save sajjadyousefnia/edf137f1f07adcbb253465104df4eab0 to your computer and use it in GitHub Desktop.
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();
while(var4.hasNext()) {
Object element$iv$iv$iv$iv = var4.next();
int p1 = ((Number)element$iv$iv$iv$iv).intValue();
if (filterLessThanTwo(p1)) {
destination$iv$iv$iv$iv.add(element$iv$iv$iv$iv);
}
}
List newList$iv = (List)destination$iv$iv$iv$iv;
System.out.println(newList$iv);
}
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 var7 = $receiver$iv$iv.iterator();
while(var7.hasNext()) {
Object element$iv$iv$iv = var7.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