How to format string multiple variables in Scala

1 Answer

0 votes
object O {
    def main(args: Array[String]): Unit = {
        var s = "abc %d xyz %f uvw"

        val i = 859
        val d = 3.14

        s = s.format(i, d)
        println(s)
    }
}
     
     
     
     
/*
run:
     
abc 859 xyz 3.140000 uvw
    
*/

 



answered Oct 16, 2020 by avibootz

Related questions

1 answer 222 views
1 answer 126 views
126 views asked Nov 8, 2023 by avibootz
1 answer 184 views
184 views asked Oct 16, 2020 by avibootz
...