Scala - Using String interpolation to evaluate expressions Code Example

The code for Using String interpolation to evaluate expressions

println("Using String interpolation to evaluate expressions")

val age: Int = 21
println(s"Are you 21 year-old = ${age == 21}")
println(s"Are you 25 year-old = ${age == 25}")
println(s"Are you eligible for voting = ${age >= 18}")

/*
Output:
Using String interpolation to evaluate expressions
Are you 21 year-old = true
Are you 25 year-old = false
Are you eligible for voting = true
*/
Code by IncludeHelp, on August 8, 2022 03:14

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.