val numberMembers = 5 //automatically inferred type Int val percentage = 80 / 100 percentage = 30 //does not compile var percentage = 80 / 100 percentage = 30 //compiles
val numberMembers = 5 //automatically inferred type Int val percentage = 80 / 100 percentage = 30 //does not compile var percentage = 80 / 100 percentage = 30 //compiles
val numberMembers = 5 //automatically inferred type Int val percentage = 80 / 100 percentage = 30 //does not compile var percentage = 80 / 100 percentage = 30 //compiles
val numberMembers = 5 //automatically inferred type Int val percentage = 80 / 100 percentage = 30 //does not compile var percentage = 80 / 100 percentage = 30 //compiles
is not null at this point textView.text = name } // There are whole bunch more - .with{} .run{} - with slight diferences // Can also just do a normal null check!
the new hello() method val hi = "Kotlin !".hello() Hello Kotlin ! fun TextView.getFloatValue() : Float { return 0f } val foat = textViewHello.getFloatValue()
the new hello() method val hi = "Kotlin !".hello() Hello Kotlin ! fun TextView.getFloatValue() : Float { return 0f } val num = textViewHello.getFloatValue()
"Work started") val result = job() Log.d(TAG, "Work Fin") return result } val number = executeWork { 100 * 5 } Log.d(TAG, "Result: $number") val stringCalc = executeWork { "Rebecca".plus(" Hello") } Log.d(TAG, "String: $stringCalc") Work started Work Fin Result: 500 Work started Work Fin String: Rebecca Hello
"Work started") val result = job() Log.d(TAG, "Work Fin") return result } val number = executeWork { 100 * 5 } Log.d(TAG, "Result: $number") val stringCalc = executeWork { "Rebecca".plus(" Hello") } Log.d(TAG, "String: $stringCalc") Work started Work Fin Result: 500 Work started Work Fin String: Rebecca Hello
"Work started") val result = job() Log.d(TAG, "Work Fin") return result } val number = executeWork { 100 * 5 } Log.d(TAG, "Result: $number") val stringCalc = executeWork { "Rebecca".plus(" Hello") } Log.d(TAG, "String: $stringCalc") Work started Work Fin Result: 500 Work started Work Fin String: Rebecca Hello
tell it otherwise (ie mark it as open ) - Workarounds but seem unnecessary https://antonioleiva.com/mockito-2-kotlin/ http://hadihariri.com/2016/10/04/Mocking-Kotlin-With-Mockito/
code. Battled with Lambda syntax, it sometimes doesn’t fll in all the blanks nicely Solution - Write it in Java, then copy paste the java into your Kotlin fle and it’ll auto convert
infnite loop or exception throwing Unit - default return type for a function Any - Default Super Type (similar to Java’s Object type) http://natpryce.com/articles/000818.html