Start with upper letter

Report a typo

Scally wrote a program to make the first letter of the input string upper case and print the result. But the program failed with some specific cases like empty input string, when it should print an empty line. Correct the program with exhaustive matching in mind.

Sample Input 1:

test

Sample Output 1:

Test
Write a program in Scala 3
@main def startWithUpper =
scala.io.StdIn.readLine() match {
case s => println(s.head.toUpper + s.drop(1))
}
___

Create a free account to access the full topic