On 2012-10-17 00:23, Jonathan M Davis wrote:
2. Or make it a range (see http://dlang.org/statement.html#foreach_with_ranges
and http://ddili.org/ders/d.en/ranges.html ), which would probably be a bad
idea, since containers really shouldn't be ranges.
Why is that a bad idea?
--
/Jacob
On Wednesday, October 17, 2012 08:14:45 Jacob Carlborg wrote:
On 2012-10-17 00:23, Jonathan M Davis wrote:
2. Or make it a range (see
http://dlang.org/statement.html#foreach_with_ranges and
http://ddili.org/ders/d.en/ranges.html ), which would probably be a bad
idea, since containers
On 2012-10-17 08:17, Jonathan M Davis wrote:
For starters, iterating over the container would empty it.
Right, but that is really weird, in my opinion.
--
/Jacob Carlborg
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
On Wed, Oct 17, 2012 at 06:58:52PM +0200, 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
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
On Wednesday, October 17, 2012 10:08:15 H. S. Teoh wrote:
On Wed, Oct 17, 2012 at 06:58:52PM +0200, 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
1. Define opApply (see section labeled Foreach over Structs
and Classes with
opApply after here:
http://dlang.org/statement.html#foreach_with_ranges)
2. Or make it a range (see
http://dlang.org/statement.html#foreach_with_ranges
and http://ddili.org/ders/d.en/ranges.html ), which would
I want to do something like this (Collection is a custom type):
Collection x = new Collection();
x.add(something);
x.add(somethingElse);
foreach(type value; x)
{
writeln(value);
}
Collection is a class with a private array member variable which
actually holds the collection data entered
On Wednesday, October 17, 2012 00:03:46 Gary Willoughby wrote:
I want to do something like this (Collection is a custom type):
Collection x = new Collection();
x.add(something);
x.add(somethingElse);
foreach(type value; x)
{
writeln(value);
}
Collection is a class with a private
10 matches
Mail list logo