ReturnIf, ExitIf and ContinueIf
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
I suggest to add conditional terminate statements say:
`Return?`, `Exit?` and `Continue?`
It will be more readable if it were
`ReturnIf`, `ExitIf`, and `ContinueIf` but they can be thought as they were ment to be used inside If blocks only, which is not true.
Syntax:
`Return? Expr1`
`Return? (Expr1, Expr2,....., Exprn)`
These conditional statements will be executed only if one of the expressions is true or is not nothing. (I prefer using if instead of ?)
Use case:
```
For i = 0 to N
Return? Find(i)
Next
```
Or As I prefer:
```
For i = 0 to N
ReturnIf Find(i)
Next
```
This is a shortcut for
```
For i =0 To N
Dim f = find(i)
If f then return f
Next
```
Example 2:
```
For i = 0 to N
ReturnIf (Foo1(i), Foo1(i), Foo3(i))
Next
```
This is a shortcut for
```
For i =0 To N
Dim f = Foo1(i)
If f then return f
f = Foo2(i)
If f then return f
f = Foo3(i)
If f then return f
Next
```
Look at a real code sample here https://github.com/dotnet/vblang/issues/382#issuecomment-466815418
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.