[swift-evolution] [Idea] custom infix functions
Adrian Zubarev
adrian.zubarev at devandartist.com
Fri Apr 22 14:06:58 CDT 2016
I’d like to throw an idea in the room and see where this will go.
What if Swift would allow us to create custom infix functions?
Does Swift need to ability of infix functions?
How powerful can such a feature be?
Pros and cons?
There is a discussion about the `with` statement which we could develop with infix functions like so:
infix func with<T: AnyObject>(lhs: T, rhs: @noescape (T) -> Void) {
rhs(lhs)
}
class A {
func foo() {}
}
let instance: A = A() with {
$0.foo()
}
So what does the Swift community think about that idea?
--
Adrian Zubarev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160422/2a951211/attachment.html>
More information about the swift-evolution
mailing list