<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Generally, if you're using guard, you're looking for something that your program requires before moving on. If you get nil back, you probably want to do more than just return nil. When you're developing something, returning nil is simply convent, but doing something about that so the user realizes something has gone wrong is also important.</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">At the same time, I don't see why we couldn't have both: &nbsp;guard and guard else. Much like ARC, couldn't the compiler provide a case where lines that only specify guard automatically return nil and guards that specify an else run the specified else in that instance?</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Myles<br><br>Sent from my iPhone</div><div><br>On Feb 10, 2016, at 10:40 PM, Tighe Racicot via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">Hey everyone,&nbsp;<div><br></div><div>I feel that `guard` could be a little more Swifty and would like to start a conversation concerning it.</div><div><br></div><div>For example, I often have a function whose job depends on an optional having a value, and so I guard-let at the start and return if the guard fails. Or if the function returns an optional type, I'll simply return nil if guard fails.&nbsp;</div><div><br></div><div>Can we improve on the general fallback case? Could we simply say:</div><div><br></div>func noReturn() {<br>&nbsp; &nbsp; guard let aValue = someOptional<br><div>&nbsp; &nbsp; ....</div><div>}</div><div><br></div><div>and have that imply "else { return <i>void or nil</i>&nbsp;}"</div><div><br></div><div>What are your thoughts?</div><div><br></div><div>Tighe</div><div><br></div></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>