Home »
Code Examples »
Scala Code Examples
Scala - Using 's' and 'f' interpolation to format numbers Code Example
The code for Using 's' and 'f' interpolation to format numbers
println("Using 's' and 'f' interpolation to format numbers")
val percentage: Double = 88.5
println(s"You got $percentage")
println(f"You got $percentage%.2f")
/*
Output:
Using 's' and 'f' interpolation to format numbers
You got 88.5
You got 88.50
*/
Code by IncludeHelp,
on August 8, 2022 03:22