If you want a chance to your idea propose some code and some tests
H E L L O
1 2 3 4 5
-5 -4 -3 -2 -1
hello from: 2 to: -2 -> ell ok
'hello' from: 2 to: -2 -> ello
'hello' from: 2 to: 0 -> ???
This is strange because I thought intuitively and wrong that it would be means
complete
from: 2 toFromEnd: 2
from: 2 to: -2
So do you have other usage of negative index in ruby?
Because I'm not sure I like that?
Stef
>> copyFrom: 1 to: does not convey that you should pass the second
>> argument starting reverse.
>
> Well, in ruby it's a general convention that negative indices start
> counting from the right. A reasonable implementation would change all
> sequenceable collections such that they accept negative indices.
>
> In Phexample syntax:
>
> ((1 to: 5) at: -2) should = 4.
>
> The alternative is to always have two accessors, then of course non-negative:
>
> (1 to: 5) atFromEnd: 2) should = 4.
>
> and:
>
> ('hello' from: 2 toFromEnd: 2) should = 'ell'
>
> I clearly prefer the negative indices. Things you do all the time can
> be much shorter than things you don't do so often. Huffman-encode your
> programming :)
>
> Cheers,
>
> Niko
>
>
> --
> http://scg.unibe.ch/staff/Schwarz
> twitter.com/nes1983
> Tel: +41 076 235 8683
>
> _______________________________________________
> Pharo-project mailing list
> [email protected]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project