Last active
August 17, 2020 19:42
-
-
Save wispborne/5d7bde79a3967b27d9e25a74bccfdad7 to your computer and use it in GitHub Desktop.
Comparison of Java to Kotlin for various simple methods.
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 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; | |
| } |
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
| 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