[swift-evolution] Rename 'guard' to 'ensure'

Radosław Pietruszewski radexpl at gmail.com
Tue Feb 23 02:54:48 CST 2016


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”…

The only problem I have is that “ensure” exists in a different language I know (Ruby), where it has different meaning.

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 ;)

— Radek

> On 19 Feb 2016, at 22:49, John Flanagan via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 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.
> 
> Example:
> 
> ensure foo != nil else {
>    return;
> }
> 
> -John
> _______________________________________________
> 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/20160223/f2a0fbdb/attachment.html>


More information about the swift-evolution mailing list