[swift-evolution] "with" operator a la O'Caml?
tali at admingilde.org
Tue Dec 20 08:44:39 CST 2016
Am 2016-12-19 20:44, schrieb Erica Sadun via swift-evolution:
I don't like where this is heading.
If you want to introduce method cascading, then have a look at Dart.
E.g. the example from the pull request could be something like this:
let questionLabel = UILabel()
..textAlignment = .Center
..font = UIFont(name: "DnealianManuscript", size: 72)
..text = questionText
The expression could still work on a mutable struct/class which later
immutable by using the `let` assignment.
The other example which silently creates a new instance is even worse.
If you want to do something like this, then please do it more
let fewerFoos = foos.clone()
Anyway, all of this is simply syntactic sugar and should wait...
More information about the swift-evolution