dotnet / dotnet/vblang

[Proposal] Select Case ? pattern

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

Description

I suggest to allow to composing the select case expr as a pattern using `?` like this:

```VB.NET
Dim X = "a test"
Select case X.StartsWith(?)
Case "a", "b"

Case "c"

Case Else

End Select
```

It will be lowered to:
```VB.NET
If X.StartsWith("a") OrElse X.StartsWith("b")

ElseIf X.StartsWith("c")

Else

End if
```

I also suggest to allow using members of the Select expr in the cases:
```VB.NET
Select Case X
Case "test"

Case .StartsWith("a")

Case Like "*s*"

Case .Contains("a")

Case .Substring(1, 2) = "ab"

End Select
```

the case will considered to have an embedded with applied on the case expr only not its body, and it will have effect over any outer with. The above syntax can be lowered to if statement.

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.