[swift-evolution] What about a VBA style with Statement?
Erica Sadun
erica at ericasadun.com
Wed Apr 13 10:51:50 CDT 2016
> On Apr 13, 2016, at 7:50 AM, Benzi via swift-evolution <swift-evolution at swift.org> wrote:
>
> The closest right now you can achieve would be:
>
> func with<T>(item:T, apply:(T)->Void) {
> apply(item)
> }
>
>
> let label = UILabel()
> label.highlighted // defaults to false
>
> with(label) {
> $0.highlighted = true
> }
>
> label.highlighted // is now true
As a reference type, you can just go ahead and assign:
let label = UILabel()
label.highlighted = true
-- E
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160413/889ec774/attachment.html>
More information about the swift-evolution
mailing list