Skip to content

Instantly share code, notes, and snippets.

@GulajavaMinistudio
Forked from ademar111190/lambdaExample.java
Created December 28, 2017 03:47
Show Gist options
  • Save GulajavaMinistudio/6cf6ea3e77e9f4b0c220a8249cd55314 to your computer and use it in GitHub Desktop.
Save GulajavaMinistudio/6cf6ea3e77e9f4b0c220a8249cd55314 to your computer and use it in GitHub Desktop.
One month with Kotlin: lambda example
// Using Lambdas on Kotlin
val items = ArrayList<String>()
items.sortBy { item ->
item.length()
}
//or more implicity
items.sortBy { it.length() }
//------------------------------------------------------------------------------
// Using the nearest from Lambdas in Java 7
ArrayList<String> items = ArrayList();
Collections.sort(items, new Comparator<String>(){
@Override
public int compare(String s1, String s2) {
return s1.length() - s2.length();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment