3 ms·
As someone unfamiliar with C#, it's strange that the default tuple element names start numbering at 1 (Item1, Item2...) Anyone know why it doesn't start with I
by e28eta 10y ago
As someone unfamiliar with C#, it's strange that the default tuple element names start numbering at 1 (Item1, Item2...)
Anyone know why it doesn't start with Item0?
- tintoy 10y agoPerhaps it's because they're item numbers, not indexes? As far as I can tell, C# uses 0-based indexing because most similar languages use 0-based indexing.
- icecube 10y agoIt has to due with history. Traditionally, other languages (such as Scala, Haskell and ML) with statically typed tuples start at index 1 instead of 0.
- e28eta 10y agoThanks! It stood out to me because Swift uses 0-based, and I suppose I either forgot or never used it in my brief exposure to Haskell & ML.
- ellism 10y agoFor what it's worth, I'm the one of the folks that designed the original tuple class (the reference type, System.Tuple, that shipped before hand). At the time, we picked one based indexing because we felt it sounded more natural when spoken allowed (mirroring saying something like: This is the first Item in the tuple). I would expect that the design bled over into ValueTuple, which looks very similar to the reference version, except, of course, it is a value type.