Array Slice Ranges

Kristian Kilpi kjkilpi at gmail.com
Thu Nov 9 11:33:54 PST 2006


On Thu, 09 Nov 2006 06:52:40 +0200, %u <trevorparscal at hotmail.com> wrote:

> I'm learning ruby right now, and I noticed they use a very cool syntax  
> for ranges.
>
> 0..5 means 0, 1, 2, 3, 4, 5
> 0...5 means 0, 1, 2, 3, 4
>
> The current array slicing is useful half the time and a pain in the arse  
> the
> other half, so I was wondering if anyone else has mentioned this idea  
> for D
> before...
>
> - Trevor

I wouldn't mind that the following would be possible in D:

1 .. 3 = 1, 2

1 ... 3 = 1, 2, 3

To me that would be easy to remember, and not too error-prone. But that's  
just me.
Then it would be fun to take turns with D and Ruby! :) Well, actually I  
think it would be fun even now because '..' means different range in D and  
Ruby.

But if '...' is considered too similar with '..', how about the following?

1 -> 3 = 1, 2, 3



More information about the Digitalmars-d mailing list