Is it possible to overload the index operator in Scala?
If yes, what would the scala version of this c++ example look like?
class Foo {
int data[7];
...
public:
int& operator[](size_t i) { return data[i]; }
int operator[](size_t i) const { return data[i]; }
...
};
The index operator in scala is (), and you can define a method which looks like it. You need to define an apply method.