It works in iOS playground, but not in MacOS playground, either Xcode 16.4 or 26.0ß6.
So, that's definitely a bug you should report.
You got the answer in your SO post: https://forums.swift.org/t/why-is-there-a-type-of-expression-is-ambiguous-without-a-type-annotation-error-when-using-a-ternary-operator-on-inferred-function-types-in-swift/77306/2
As said, this works:
func chooseStepFunction(backward: Bool) -> (Int) -> Int {
let res = oneStepBackward ? stepBackward : oneStepForward
return res
}
Topic:
Programming Languages
SubTopic:
Swift
Tags: