Hey there!
Welcome to ClearUrDoubt.com.
In this post, we will look at a Scala program to make the first character uppercase of each word of an List.
Let’s look at the program:
1 2 3 4 5 6 7 8 |
object CamelCaseWordMaker extends App { def capitalize(input: List[String]): List[String] = input .map(str => str.split(" ")) .map(arr => arr.map(_.capitalize).mkString(" ")) println(capitalize(List("hello", "world", "hello world"))) } |
Output:
Happy learning.
Please leave a reply in case of any queries.