July 05, 2005
> 
> I write someArray[$-1] to get the last element.
> 

Personally, I think using # is way more descriptive than $... $ looks like a php variable.. some might say # looks like a cold fusion varaible, but honestly, cold fusion is crap, so I just ignore it...

# also seems like "number of elements"... $ has no other natural meaning...

list[# - 5 .. #]

should give you the last 5 elements of the array.

Also, I have another idea. using "..." should mean, to the end. so

list[4 ...]

means, from 4 on. so...

list[# - 5 ...]

means, the last 5 :)

Just an idea. Won't break existing code.

-- 
Thanks,
Trevor Parscal
www.trevorparscal.com
trevorparscal@hotmail.com
July 06, 2005
Hi,

In article <daf0km$umn$1@digitaldaemon.com>, Trevor Parscal says...
>> I write someArray[$-1] to get the last element.
>Personally, I think using # is way more descriptive than $... $ looks like a php variable.. some might say # looks like a cold fusion varaible, but honestly, cold fusion is crap, so I just ignore it...
>
># also seems like "number of elements"... $ has no other natural meaning...
>list[# - 5 .. #]
>should give you the last 5 elements of the array.

You have my vote. I agree wholeheartedly.

>Also, I have another idea. using "..." should mean, to the end. so
>
>list[4 ...]
>means, from 4 on. so...
>list[# - 5 ...]
>means, the last 5 :)
>
>Just an idea. Won't break existing code.

I also like this idea. To make it simpler we could just use .. and leave one (or both) of the ends blank. So that:

array[a ..] == array[a .. #];
array[.. b] == array[0 .. b];
array[..]   == array[0 .. #] == array;

Just thinking out loud.
--AJG.


>
>-- 
>Thanks,
>Trevor Parscal
>www.trevorparscal.com
>trevorparscal@hotmail.com


July 06, 2005
On Wed, 6 Jul 2005 01:05:17 +0000 (UTC), AJG <AJG_member@pathlink.com> wrote:
> In article <daf0km$umn$1@digitaldaemon.com>, Trevor Parscal says...
>>> I write someArray[$-1] to get the last element.
>> Personally, I think using # is way more descriptive than $... $ looks
>> like a php variable.. some might say # looks like a cold fusion
>> varaible, but honestly, cold fusion is crap, so I just ignore it...
>>
>> # also seems like "number of elements"... $ has no other natural meaning...
>> list[# - 5 .. #]
>> should give you the last 5 elements of the array.
>
> You have my vote. I agree wholeheartedly.

I dont mind $, that said, I don't mind # either.

>> Also, I have another idea. using "..." should mean, to the end. so
>>
>> list[4 ...]
>> means, from 4 on. so...
>> list[# - 5 ...]
>> means, the last 5 :)
>>
>> Just an idea. Won't break existing code.
>
> I also like this idea. To make it simpler we could just use .. and leave one (or both) of the ends blank. So that:
>
> array[a ..] == array[a .. #];
> array[.. b] == array[0 .. b];
> array[..]   == array[0 .. #] == array;
>
> Just thinking out loud.

This idea has been proposed before, along with many others. Do a search, you'll see what I mean.

Regan
1 2 3 4 5
Next ›   Last »