Please enable JavaScript.
Coggle requires JavaScript to display documents.
Defining and calling functions (Extension functions (fun String.lastChar()…
Defining and calling functions
Collections
setOf(1, 2, 3)
hashMapOf(1 to "one", 7 to "seven", 10 to "ten")
arrayListOf(1,2,3)
hashSetOf(1, 2, 3)
Extension functions
its a member class that declares outside of it
fun String.lastChar() : Char = this.get(this.length - 1)
Receiver type is String
type on which extension is defined
Receiver object is this
to use needs to import
import strings.lastChar()
if a extension function has the same name of member class, extension function has precedence
its a static member class
varargs
in kotlin is varargs instead of ...
depacking array *array
spread operator *
infix call
1 to "one"
1.to("one")
both are same
destructuring declaration
val (number, name) = 1 to "one"