Hi Sanjay,

2015-03-10 14:47 GMT+01:00 Sanjay Minni <s...@planage.com>:

>
> sorry folks ...
>
> so back to terra firma ...
>
> 1. Is there any way to query an object to finds its index value in the
> original collection ...
> say when all the objects from a collection are displayed and user clicks on
> one item - I want to locate the object back in the collection. Knowing the
> index for me would be most efficient.
>

aCollection indexOf: anElement

You will often find this code in list-related gui objects.


>
> 2. ... also Is there any way to know if I am on the last element ...
>

aCollection last == anElement


>
> otherwise I will have to explicitly store the index values ...
>

If you do it more than once per iteration of the collection, it is probably
faster to store the indexes. But I wouldn't do it for anything GUI related;
indexOf: is efficient enough.

Regards,

Thierry

Reply via email to