https://kotlinlang.org logo
#getting-started
Title
# getting-started
t

twisterrob

01/27/2018, 9:03 PM
regarding `this`:
Copy code
class C {
	fun f(arg: String) {
		val x /*: C inferred*/ = when (arg) { /*...*/ else -> this }
	}
}
regarding
val
and
expr
Copy code
fun f(arg : String) {
	val num = arg.toInt()
	when(num) {
		1,2,3 -> println(num)
	}
}
compare to:
Copy code
when(arg.toInt()) {
	1,2,3 -> println(this) // this is not available as `arg.toInt()`
}