Arvin Schnell wrote:
     * @usage sublist ([ "a", "b", "c"], 0) -> [ "a", "b", "c" ]
     * @usage sublist ([ "a", "b", "c"], 2) -> [ "c" ]
It does not beat ruby's elegance. ;-)

In ruby, Arrays have operator[], where with one parameter it returns an Object (the object at the given index), but if operator [] has two parameters, then it returns an array with the given range.

[1,2,3,4,5,6][1]
=> 2

[1,2,3,4,5,6][1,3]
=> [2, 3, 4]

Of course you can do
a = [1,2,3,4,5,6]
a[1] or a[1,3]

I just wanted to enhance that the method [] is available on a explicit array as much as you can see Integer methods doing 3.methods or get the abs by doing -10.abs

Duncan

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to