Post

Replies

Boosts

Views

Activity

Is using `static func` to define a operator confusing with normal `static func` functions?
For example, in the code block below, why do we need to call it using Int.hey(lhs: 5, rhs: 6), while the other one just define the operator in the same time? Wouldn't it be confusing? Will something like operator func hey(lhs: Self, rhs: Self) -> Self be clearer? public protocol Multiplyable {   static func &(lhs: Self, rhs: Self) -> Self       static func hey(lhs: Self, rhs: Self) -> Self } extension Double: Multiplyable {   static public func &(lhs: Self, rhs: Self) -> Self {     return lhs * rhs   }       public static func hey(lhs: Self, rhs: Self) -> Self {     return lhs * rhs   } } extension Int: Multiplyable {   static public func &(lhs: Self, rhs: Self) -> Self {     return lhs * rhs   }       public static func hey(lhs: Self, rhs: Self) -> Self {     return lhs * rhs   } } let result1 = 3&4 print(result1) let result2 = Int.hey(lhs: 5, rhs: 6) print(result2)
0
0
546
Nov ’22