Home »
Code Examples »
Scala Code Examples
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