String Interpolation Example in Scala:
f, s, raw are the String Interpolation
object StringInterpolation {
def main(args:Array[String]){
val name = "Sankaranarayanan"
val height = 179.23423423
println(s"Name : $name, Height : $height")
println(f"Name : $name%s, Height : $height%f")
println(s"Hello\t\t\tworld!")
println(raw"Hello\t\t\tworld") // Display the raw unformatted code
}
}
Result:
Name : Sankaranarayanan, Height : 179.23423423
Name : Sankaranarayanan, Height : 179.234234
Hello world!
Hello\t\t\tworld
No comments:
Post a Comment