let x: list = [40..50];
print(x[0]); // output: '40'
However, operations on lists should be allowed directly:
print([40..50][0]); // should output: '40', but panics
Implementing this effectively should probably go hand-in-hand with implementing lists as first-class objects that implement an 'Enumerable' trait, whose implementation would look something along the lines of:
extend List with Enumerable<Any> {
fn index(ind: int) : Any {
return self.list[ind];
}
... // other functions here
}
In the future, this could also allow functions like .len() to be implemented for list types.
The following code executes fine:
However, operations on lists should be allowed directly:
Implementing this effectively should probably go hand-in-hand with implementing lists as first-class objects that implement an 'Enumerable' trait, whose implementation would look something along the lines of:
In the future, this could also allow functions like
.len()
to be implemented for list types.