Slide 31
Slide 31 text
31
Functions
fun reformat(str: String,
normalizeCase: Boolean = true,
upperCaseFirstLetter: Boolean = true,
wordSeparator: Char = ' '): String {
//...
}
Named Parameters & default values
reformat(str, true, true, '_') // old way to call
reformat(str, wordSeparator = '_') // using default values & named params
fun String.hello(): String{
return "Hello " + this
}
val hi = "Arnaud !".hello()
println("$hi") // Hello Arnaud !
Extension