range.put() to Empty Array Causes Error?

Vijay Nayar madric at gmail.com
Sun Jun 17 11:07:49 UTC 2018


This code breaks with the following error:
void main()
{
	import std.range;
   	int[] vals = [];
	vals.put(3);
}
/src/phobos/std/range/primitives.d(2328): Attempting to fetch the 
front of an empty array of int

The following code has no error:
void main()
{
	import std.range;
   	int[] vals = [1];
	vals.put(3);
}

Why is range.put() not allowed for empty arrays?




More information about the Digitalmars-d-learn mailing list