>
> 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.

==============================
indexOf: anElement
"Answer the index of the first occurrence of anElement within the
receiver. If the receiver does not contain anElement, answer 0."

^ self indexOf: anElement ifAbsent: 0
==============================

don't be afraid to look inside Pharo and on Collection protocols.


> 2. ... also Is there any way to know if I am on the last element ...
>
I'm not sure what you are trying to achieve, but you can just compare
against the last element

(myCollection last = myObject) ifTrue: [ do something ]

Reply via email to