Convert Char into a String
You can use the method take
as followed:
scala> val s = "abcdef"
s: String = abcdef
scala> val first = s.take(1)
first: String = a
scala>
String doesn't have a .first()
function. Do you mean .head
?
Using head
and returning a String is as simple as:
s.head.toString