Scala - How to use a prefix, suffix, and separator with mkString? Code Example

The code for How to use a prefix, suffix, and separator with mkString?

val numbers = Array(10, 20, 30)

var result = numbers.mkString("[", ",", "]")
println(result)

result = numbers.mkString("{", ",", "}")
println(result)

result = numbers.mkString("( ", " # ", " )")
println(result)


/*
Output:
[10,20,30]
{10,20,30}
( 10 # 20 # 30 )
*/
Code by IncludeHelp, on August 10, 2022 23:56

Comments and Discussions!

Load comments ↻






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