Store operator function in a variable

I have a question about how properly store operator in a variable.

let function1: (Int, Int) -> Int = (+) // ok. Single element tuple?
let function2: (Int, Int) -> Int = +   // error: Expected expression after unary operator

// But
    
[1,2,3].reduce(0, (+)) // ok
[1,2,3].reduce(0, +)   // ok

Is this a bug or an expected behaviour?

Seems like this is the same workaround as the one for putting operators in an array:

let operators: [(Int, Int) -> Int] = [(+), (-)] // Ok
let operators: [(Int, Int) -> Int] = [+, -] // Error

This bug is tracked by https://bugs.swift.org/browse/SR-5509

1 Like

huh, so this is known issue.
Thanks!