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.
Introduction to pattern matching
Start with upper letter
Report a typo
Sample Input 1:
testSample Output 1:
TestWrite a program in Scala 3
@main def startWithUpper =
scala.io.StdIn.readLine() match {
case s => println(s.head.toUpper + s.drop(1))
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.