我似乎无法重载“。”不确定这是编译器错误还是我正在做的事情:
@infix func . (a: Int, b: Int) -> Int {
return a * b
}
我得到错误:
函数声明中的预期标识符
大括号语句 block 是未使用的闭包
最佳答案
你不能重载 '.'它是该语言的保留标记。但是,您可以重载 .. 和 ... 运算符。
Operators are made up of one or more of the following characters: /, =, -, +, !, , %, <, >, &, |, ^, ~, and .. That said, the tokens =, ->, //, /, */, ., and the unary prefix operator & are reserved. These tokens can’t be overloaded, nor can they be used to define custom operators.
关于swift - 重载 "."产生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24092525/