infix operator >>= {associativity left} public func >>=<A,B>(a: A?,f: A -> B?) -> B? { if let a = a { return f(a) } else { return .None } }
然后我想使用它我的主要应用程序。我将SampleFramework导入到我的源文件,然后我写了这个代码来测试它:
NSURL(string: "www.google.com") >>= { println("\($0)") }
它没有编译。这里是Xcode的错误消息:
Ambiguous operator declarations found for operator. Operator is not a
known binary operator