Re:The search for easier safe systems programming
by neonsunset on Wednesday May 08, 2024 @06:02PM
(#40303165)
(slight correction: `var foo = [1, 2, 3];` requires natural types for collection literals (it needs to infer the best type for var), this is coming in C# 13 (.NET 9, this November), but otherwise `int[] numbers = [1, 2, 3];` works)
[ Parent
| on HN ]
Re:The search for easier safe systems programming
by kkukshtel on Thursday May 09, 2024 @11:33AM
(#40309289)
You're right! I remember some session where they talked about wanting to infer a natural type for stuff like that but its obviously a big question. But as you said declaring the type directly allows it to work. However the other nice part is that you _can_ do this:
void myFunc(List<int>){}
myFunc([1,2,3]);
The expression sytanx can infer the type from the caller syntax so you can just inline the array declaration.