try-catch-finally as expression
I am stuck with an exercise on
hyperskill.org at try-catch-finally exception(exercise: Parting words).
Try-catch-finally should be used as an expression. In the "try" block an input string is required to check if it consists of two words separated by a space. If not(there's only one word given), an exception is thrown in the "catch" block. Otherwise the code in the "try" block should be evaluated. How can it be achived?
fun pepTalk(name: String) : String {
val array = name.split("...