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
| class Person (var name:String, var lastName:String, var weight:Double) { | |
| val fullName = "$name $lastName" | |
| } |
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
| class Person () { | |
| fun run() { /*doSth*/ } | |
| fun walk() { /*doSth*/ } | |
| fun jump() { /*doSth*/ } | |
| } |
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
| class Person (var name:String, var lastName:String, var weight:Double) { | |
| //.. | |
| fun jump() { | |
| weight -= 0.1 | |
| /*doSth*/ | |
| } | |
| } |
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
| person.name = "Igor" | |
| person.weight = 79 | |
| person.jump() | |
| person.jump() | |
| person.jump() |
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
| class Person (var name:String, var lastName:String, var weight:Double) { | |
| val fullName | |
| get() = "$name $lastName" | |
| } |
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
| //BAD | |
| class Person () { | |
| private var weight:Double = 0 | |
| fun setWeight(weight:Double) { | |
| this.weight = weight | |
| } | |
| fun getWeight(): Double { | |
| return weight |
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 main(args: Array<String>) { | |
| val range = 1..10000 | |
| logTime("benchmarkPlusOperator") { benchmarkPlusOperator(range) } | |
| logTime("benchmarkStringAppend") { benchmarkStringAppend(range) } | |
| } | |
| fun benchmarkPlusOperator(range:IntRange) { | |
| var str = "" | |
| range.forEach { str += "abc" } |
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 class MyApplication extends Application { | |
| public void onCreate() { | |
| super.onCreate(); | |
| Stetho.initializeWithDefaults(this); | |
| } | |
| } |
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
| textView.addTextChangedListener(new TextWatcher() { | |
| public void afterTextChanged(Editable s) { | |
| //do something | |
| } | |
| public void beforeTextChanged(CharSequence s, int start, int count, int after) { | |
| //do something | |
| } |
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
| class View { | |
| private var beforeTextChangedListener: (() -> Unit)? = null | |
| private var afterTextChangedListener: (() -> Unit)? = null | |
| private var onTextChangedListener: (() -> Unit)? = null | |
| fun setBeforeTextChangedListener(listener: () -> Unit) { | |
| beforeTextChangedListener = listener | |
| } | |
| fun setAfterTextChangedListener(listener: () -> Unit) { |