We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A few people have been comparing parts of Belay to the Swift guard statement so I looked to see if there was any inspiration to be found there.
Here in its own basic form:
guard condition else { // statements // exit }
It is very similar to:
expect.isTrue(condition) { // statements // exit }
Belay also provides a variant that is very useful when a false condition can be handled without exiting from the parent:
expect(condition) { // statements // does not need to exit }
And of course if one doesn't need to handle expectations globally it's just as easy to write:
if (!condition) { // … }
The Swift guard also supports an "optional binding declaration":
guard let constantName = someOptional else { // … }
Which is very similar to:
val constantName = expect.isNotNull(someOptional) { // … }
One major difference: Swift support multiple bindings, Belay does not in this case.
And another: the variables assigned a value from an optional binding can be used as part of the condition:
guard let constantName = someOptional, condition(constantName) else { // … }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
A few people have been comparing parts of Belay to the Swift guard statement so I looked to see if there was any inspiration to be found there.
Here in its own basic form:
It is very similar to:
Belay also provides a variant that is very useful when a false condition can be handled without exiting from the parent:
And of course if one doesn't need to handle expectations globally it's just as easy to write:
The Swift guard also supports an "optional binding declaration":
Which is very similar to:
One major difference: Swift support multiple bindings, Belay does not in this case.
And another: the variables assigned a value from an optional binding can be used as part of the condition:
The text was updated successfully, but these errors were encountered: