Avatar
omochimetaru 7/13/2017 4:06 AM
+// FIXME: replace this with a computed var named `...` when the language makes +// that possible. +public enum UnboundedRange_ { + public static postfix func ... (_: UnboundedRange_) -> () { + fatalError("uncallable") + } +} +public typealias UnboundedRange = (UnboundedRange_)->() + public subscript(x: UnboundedRange) -> SubSequence { + get { + return self[startIndex...] + } + set { + self[startIndex...] = newValue + } + }
4:07 AM
あっ、これ、そういうことか?
4:08 AM
... は 演算子で、 形式的に UnmoundedRange_ を引数1個取って消化する関数で
4:08 AM
subscript は、 UnboundedRange_ を消化する関数を受け取るオーバーロードなのか。
4:09 AM
お、このテクニックで、好きな演算子を、演算子単体で存在する型として取り回すことができるな。