On 10/17/2012 09:58 AM, Jacob Carlborg wrote: > On 2012-10-17 17:45, Jonathan M Davis wrote: > >> Well, what would you expect? Ranges are consumed when you iterate over >> them. >> So, if an container is a range, it will be consumed when you iterate >> over it. >> That's the way that it _has_ to work given how ranges work, and that's >> why you >> overload opSlice to return a range which is iterated over rather than >> making >> the container itself a range. > > How does this work with built-in arrays?
Array is a separate concept than slice; a slice provides access to the elements of an array. Arrays are containers that are owned by the runtime, slices are ranges over their elements. Only the slices are consumed.
Ali