Kotlin (programming language): Difference between revisions

Content deleted Content added
K0zka (talk | contribs)
Tools: added <ref>
K0zka (talk | contribs)
Semantics: more examples
Line 53:
 
<source lang=Scala>
fun foosayHello(maybeNullmaybe : String?, neverNull : Int)
 
fun foo(maybeNull : String?, neverNull : Int)
{
// use of elvis operator
val name : String = maybe ?: "stranger"
println("Hello ${name}")
}
</source>
 
An example for the use of the safe navigation operator
<source lang=Scala>
// returns null if foo is null, or bar() returns null, or baz() returns null
foo ?. bar() ?. baz()
</source>