3 ms·
I'm pretty sure that there are a few languages where array indexing is basically calling a function that returns a reference to the cell you're accessing.
by yyhhsj0521 7y ago
I'm pretty sure that there are a few languages where array indexing is basically calling a function that returns a reference to the cell you're accessing.
- DaiPlusPlus 7y agoSince C# 1.0, any type can have an indexer property defined that can accept any parameter types and can can return anything - though it wasn't until C# 7.0 that we could return a first-class reference to a value, including array members (`public ref int this[int idx] => ref this.someArray[idx]`).
- sk5t 7y agoPerhaps not exactly what you mean, but Scala eschews [] for array access, and arr(0) returns the same as arr.apply(0).