<html><body><div>I prefer "guard". A "guard clause" is a term of art and Shawn put it nicely that the "guard" checks that no one passes beside it which fails the check.<br></div><div>"Ensure" implies to me that something will happen that ensures that the condition will hold after that which has quite a different meaning from guarding (e.g. Eiffel has "ensure" clauses for postconditions, i.e. something that is guaranteed to hold after a method has run).<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>-Thorsten<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div><br>Am 23. Februar 2016 um 09:55 schrieb Radosław Pietruszewski via swift-evolution &lt;swift-evolution@swift.org&gt;:<br><br><div><blockquote type="cite"><div class="msg-quote" style="word-wrap: break-word;" data-mce-style="word-wrap: break-word;"><div class="">I don’t have a problem with “guard”, and I have grown used to it, but I will give you that “ensure” is probably clearer. “ensure *this condition is true*”, “ensure that I can let foo = bar” — seems easier to conceptualize its meaning from syntax than “guard”…</div><div class=""><br class=""></div><div class="">The only problem I have is that “ensure” exists in a different language I know (Ruby), where it has different meaning.</div><div class=""><br class=""></div><div class="">So… I’m not sure it’s worth changing “guard” now and I probably wouldn’t be *for* the change, but I also probably wouldn’t argue against it either ;)</div><br class=""><div class=""><div class="">— Radek</div></div><br class=""><div><blockquote type="cite" class=""><div class="">On 19 Feb 2016, at 22:49, John Flanagan via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="" data-mce-href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="word-wrap: break-word;" class="" data-mce-style="word-wrap: break-word;">The functionality of ‘guard’ is great and this proposal has nothing to do with changing that. The only suggestion is that the word ‘ensure’ would better communicate what a ‘guard’ statement does to those encountering it for the first time and would make code more readable in general.<div class=""><br class=""></div><div class="">Example:</div><div class=""><br class=""></div><div class=""><span style="font-family: Courier;" data-mce-style="font-family: Courier;" face="Courier">ensure foo != nil else {</span></div><div class=""><span style="font-family: Courier;" data-mce-style="font-family: Courier;" face="Courier">&nbsp; &nbsp;return;</span></div><div class=""><span style="font-family: Courier;" data-mce-style="font-family: Courier;" face="Courier">}</span></div><div class=""><br class=""></div><div class="">-John</div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="" data-mce-href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" data-mce-href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></blockquote></div></div></body></html>