By
using template expression, you can evaluate the expression in a string. Template expression starts with $ symbol followed by a name.
Ex
var
a = 10
println("Value
of a is : $a")
Arbitrary
expression are enclosed in curly braces
var
str = "Hello World"
println("$str
length is ${str.length}")
Expression.kt
fun main(args: Array<String>) { var a = 10 var str = "Hello World" println("Value of a is : $a") println("$str length is ${str.length}") }
Output
Value of a is : 10 Hello World length is 11
No comments:
Post a Comment