Nothing-coalescing operator for more than two expressions
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
While writing this:
```
Function FindTSI(frm As Form) As ToolStripItem
Return If(If(CheckToolStrip(frm.ContextMenuStrip),
CheckToolStrip(frm.MainMenuStrip)),
CheckControls(frm))
End Function
```
I wondered why doesn't VB.NET use the `??` operator instead? It is more readable and used in C#. It is not strange, since VB used the `?` like in `x?.y`
The above code will became:
```
Function FindTSI(frm As Form) As ToolStripItem
Return CheckToolStrip(frm.ContextMenuStrip) ??
CheckToolStrip(frm.MainMenuStrip) ??
CheckControls(frm)
End Function
```
Which is shorter and clearer!
# Update:
May be we need an If-like statment that accepts more than two arguments. If can't do that because the rhree arguments form has a different job, so I suggest to use rhe Coalesce statement instead:
`dim x = Coalesce(a, b, c, d, e)`
If sould work like If.
Update 2:
Maybe we can use Select as the multi param if. It is short, familiar. reserved and analogous to if:
```
Dim x = If (a, b)
Dim y = Select(a, b, c, d, e)
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.