If you make a mistake in your post you have a one-hour window in which you can edit it. If you're outside of that one hour, just reply to your original post. There's no need to create a duplicate thread for the same issue just because you didn't format something properly; that just clutters the forums. Anyway, correctly formatted: func stepForward(_ input: Int) -> Int { input + 1 } func stepBackward(_ input: Int) -> Int { input - 1 } func chooseStepFunction(backward: Bool) -> (Int) -> Int { backward ? stepBackward : stepForward } // Second version func chooseStepFunction(backward: Bool) -> (Int) -> Int { if backward { stepBackward } else { stepForward } } I don't get any errors, so this can't be the code that's causing it. The first version with the ternary operator works fine. As an aside, in Swift, if your function only does one thing then you don't need the return keyword.
Topic:
Programming Languages
SubTopic:
Swift
Tags: