[swift-evolution] Proposal: Bitmask-style syntax for Method Chaining

Jacob Bandes-Storch jtbandes at gmail.com
Wed Dec 16 17:04:46 CST 2015


I'm not sure if this is truly different from the "Setup Closures"
discussion. Wouldn't some of that proposed syntax achieve exactly the same
goal?

someViewController.view.layer.{
    shadowColor = UIColor.grayColor().CGColor,
    shadowRadius = 5.0,
    shadowOffset = CGSizeMake(0.0, 0.5),
    shadowOpacity = 0.75
}


Jacob Bandes-Storch

On Wed, Dec 16, 2015 at 3:27 AM, Jakob Egger via swift-evolution <
swift-evolution at swift.org> wrote:

>
> On 15 Dec 2015, at 22:48, Chuquimia, Max via swift-evolution <
> swift-evolution at swift.org> wrote:
>
> What I propose is a natural way of assigning properties on layer with a
> syntax we are all already used to:
>
> someViewController.view.layer = [
>     .shadowColor = UIColor.grayColor().CGColor,
>     .shadowRadius = 5.0,
>     .shadowOffset = CGSizeMake(0.0, 0.5),
>     .shadowOpacity = 0.75
> ]
>
>
> You can already do something similar to this using blocks:
>
> ({
> $0.shadowColor = UIColor.grayColor().CGColor
> $0.shadowRadius = 5.0
> $0.shadowOffset = CGSizeMake(0.0, 0.5)
> $0.shadowOpacity = 0.75
> })(someViewController.view.layer)
>
> or using optional unwrapping:
>
> if let layer = someViewController.view.layer as CGLayer? {
> layer.shadowColor = UIColor.grayColor().CGColor
> layer.shadowRadius = 5.0
> layer.shadowOffset = CGSizeMake(0.0, 0.5)
> layer.shadowOpacity = 0.75
> }
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151216/b4175a69/attachment.html>


More information about the swift-evolution mailing list