dotnet / dotnet/vblang

Proposal: Using $ operator for shortening VisualBasic anonymous type declaration code

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

Description

Hi,

#### Current usage of $ operator

###### String interpolation

$ operator can using for provides the ``string.format`` function, like:

```vbnet
Dim user$
Dim project$
Dim issue%
Dim url$ = $"https://github.com/{user$}/{project$}/issues/{issue%}"
```

#### Extends the $ operator

And I think this ``$`` is also can be using for shortening anonymous type declaring:

```vbnet
Dim url$

With ${
.key = user$, .time = Now, .percent% = 52%
}
Call url.POST($)

Return $.GetJson
End With

' another $ anonymous type example
With getURL()
Call $.POST(${ .key = user$, .time = Now, .percent% = 52%})
End With
```
This anonymous type declare and usage was combine with the anonymous variable syntax in VisualBasic
> [Proposal] Improvements on the VisualBasic anonymous variable more elegant #16096

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.