www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - InputRange in arrays

reply Salih Dincer <salihdb hotmail.com> writes:
Hi, there is a feature when working with the InputRange. I don't 
know when it released available. May be somewhere D compiler 
between v2.087 and v2.096 (works) but definitely not before 
v2.087 (including)...

Anyone know this?

```d
import std.range.primitives;
void main()
{
   auto arr = [0, 1];
   arr.popFront;

   assert(arr.front == 1);
   assert(isInputRange!(typeof(arr)));
}
```

SDB 79
Mar 30 2023
parent reply Salih Dincer <salihdb hotmail.com> writes:
On Friday, 31 March 2023 at 03:39:51 UTC, Salih Dincer wrote:
 May be somewhere D compiler between v2.087 and v2.096 (works) 
 but definitely not before v2.087 (including)...
Edit: The Phobos library I'm using is corrupted. That's why the last line was giving an error. But has it always been possible for arrays to be used as if they were ranges? Thanks... SDB 79
Mar 30 2023
parent Salih Dincer <salihdb hotmail.com> writes:
On Friday, 31 March 2023 at 04:15:24 UTC, Salih Dincer wrote:
 
 ...has it always been possible for arrays to be used as if they 
 were ranges?
Playground is a very useful tool, it responds right away :)
 Up to      2.078.3: Failure with output:
 -----
 onlineapp.d(4): Error: no property 'popFront' for type 'int[]'
 onlineapp.d(6): Error: no property 'front' for type 'int[]'
 -----
 2.079.1 to 2.087.1: Failure with output:
 -----
 onlineapp.d(4): Error: no property `popFront` for type `int[]`
 onlineapp.d(6): Error: no property `front` for type `int[]`
 -----
 Since      2.088.1: Failure with output:
 -----
 onlineapp.d(4): Error: no property `popFront` for type `int[]`, 
 perhaps `import std.range;` is needed?
 onlineapp.d(6): Error: no property `front` for type `int[]`, 
 perhaps `import std.range;` is needed?
 -----
SDB 79
Mar 30 2023