I'm pretty new to Swift, so the thing is that I have an Enum and I have to return text with either Uppercase or Lowercase letters, and my code doesn't work.
enum UpLow {
case Uppercase
case Lowercase
func setCase(text: String) -> String {
switch self {
case .Uppercase:
return text.uppercased()
case .Lowercase:
return text.lowercased()
}
}
setCase(text: "example", case: .Uppercase)
}
and the error I get:
Playground execution failed:
error: demo.playground:60:5: error: expected declaration setCase(text: "example", case: .Uppercase) ^
demo.playground:47:6: note: in declaration of 'UpLow' enum UpLow { ^
Edit: I have to get this thing to work only by calling that function setCase(text: "Chosen text", case: .ChosenCase)
Exercise 5a: Create a function and an enum allows you to define this method: setCase (text: "Interstellar", case: .Uppercase) // INTERSTELLAR setCase (text: "Interstellar", case: .Lowercase) // interstellar * /