Last active
August 29, 2015 14:17
-
-
Save ademar111190/2e11683ba9df1644b194 to your computer and use it in GitHub Desktop.
One month with Kotlin: closure example
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
| // Using Closure on Kotlin | |
| button.setOnClickListener { | |
| Thread { | |
| // Amazing! Just 2 identations, 5 lines and 55 characters "lesser than a half of tweet" | |
| }.start() | |
| } | |
| //------------------------------------------------------------------------------ | |
| // Using the nearest from Closure in Java 7 | |
| button.setOnClickListener(new View.onClickListener() { | |
| @Override | |
| public void onClick(View view) { | |
| new Thread(new Runnable() { | |
| @Override | |
| public void run() { | |
| // Hummmm... 4 identations, 11 lines and 207 characters "bigger than one tweet" | |
| } | |
| }).start(); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Kotlin's version could be simplified to