Query comprehension extensions to collection initializers
- Dominant language
- No language data
- Stars
- 328
- Forks
- 71
- PR merge metrics
- No merged PRs in 30d
Description
Today in VB you can write a query expression: `From v In c Where P(v)` and you can write `New List(Of T) From { ... }`. Is it a natural extension that `New List(Of T) From v In c Where P(v)`?
I think so, but that's purely an accident of the syntax we've chosen for collection initializers--that it happens to use the `From` keyword. Curious what others think?
It would provide an easier syntax for "list comprehensions" that other language have.
> Note: This begs that we extend type inference for `New` expressions to do some type argument inference based on collection initializer values: `New List From x In 1 To 100 Step 2 Select x * x ' List of squares`. It's not as concise as just using `[` `]` like other languages, but what have cryptic symbols ever done for me?
Is this syntactic sugar for `New List(Of T)(initializer)`? That's probably easier than looping and calling `Add` a whole bunch of times (and quite possibly more performant) but wouldn't be the same for nested collection initializers to read-only properties.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.