3 ms·
Primary Constructors and Collection Syntax seem good. I think with target typed new and this new collection syntax I probably won't use var anymore.
by leosanchez 3y ago
Primary Constructors and Collection Syntax seem good.
I think with target typed new and this new collection syntax I probably won't use var anymore.
- gfna 3y agoThe old collection initialisation syntax has always felt clunky compared to many other languages, especially with more complex Dictionary types. At the same time it feels funny going back to having the type defined first since many have spent years converting explicit 'Type foo...' into 'var foo...' because the linter suggested it. Then again, perhaps this is one step towards more type inference and being able to leave out the type in more places
- ygra 3y agoPersonally, I'm still using var for most locals, but target-typed new for field and property initializers. Not every feature had to be used everywhere.
- melolife 3y agoUnlikely. The new collection literal syntax exists as the dual of the pattern matching syntax, which itself exists primarily because you can't reference a generic type by name without specifying the type parameters. If you want to write out Dictionary<Guid, ILookup<int, List<MyEntity>>> instead of having it inferred then go for it I guess.