Skip to content

Instantly share code, notes, and snippets.

@wispborne
Last active August 17, 2020 19:42
Show Gist options
  • Select an option

  • Save wispborne/5d7bde79a3967b27d9e25a74bccfdad7 to your computer and use it in GitHub Desktop.

Select an option

Save wispborne/5d7bde79a3967b27d9e25a74bccfdad7 to your computer and use it in GitHub Desktop.
Comparison of Java to Kotlin for various simple methods.
public List<MyClass> filterList(List<MyClass> list) {
List<MyClass> ret = new List<>(list.size());
for(MyClass item : list) {
if(item.someBool) {
ret.add(item);
}
}
return ret;
}
fun filterList(items:List<MyClass>) = items.filter { it.someBool }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment