Deep nesting vs early returns

Faux Amis faux at amis.com
Tue Oct 2 20:53:40 UTC 2018


On 2018-10-02 21:09, Jacob Carlborg wrote:
> On 2018-10-02 20:14, Andrei Alexandrescu wrote:
>> Kate Gregory makes a good argument on something I've often commented 
>> in code reviews: https://youtu.be/n0Ak6xtVXno?t=2682
> 
> Swift has the "guard" statement to help with early returns (and unwrap 
> optionals).
> 
> https://thatthinginswift.com/guard-statement-swift/
> https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID524
> 

Is it:
For optional binding, Swift 2 has sugar for
if let !( ){}

Or am I missing the point of the guard statement?


More information about the Digitalmars-d mailing list