dotnet / dotnet/vblang

[Proposal] "If Call" syntax sugar

Open
#32 5 comments 3 reactions 0 assignees View on GitHub
Discussion
Dominant language
No language data
Stars
328
Forks
71
PR merge metrics
No merged PRs in 30d

Description

Hi,

Assuming that we have a single method call in a single ``If`` test block, and then ``If..Then`` will be used:

```vbnet
Dim test As Boolean

' If test Then Call method()
' Or
If test Then
Call method()
End If

Dim i%

If i = 10 Then
Call method()
End If

Dim test2 = Function(str$) As Boolean
' blabla
End Function

If test2(str:="blabla") Then
Call method()
End If

' If want call multiple lines sub program
If Not test2(str:="blabla") Then
Call Sub()
' blabla
End Sub
End If
```

And I think this situation can be simplify by using a ``If Call`` syntax sugar

```vbnet
Dim test As Boolean

Call test ? method()

Dim i%

Call (i = 10) ? method()

Dim test2 = Function(str$) As Boolean
' blabla
End Function

Call test2(str:="blablabla") ? method()

' If want call multiple lines sub program
Call (Not test2(str:="blabla")) ? Sub()
' balbala
End Sub
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.