pharo-spec / Spec

Spec is a framework in Pharo for describing user interfaces.
MIT License
62 stars 65 forks source link

Add indexOf: to the List Presenter #1585

Open hernanmd opened 3 months ago

hernanmd commented 3 months ago

Consider the following usage scenario. I want to get the index of an element in my list:

| somePrimes list |
somePrimes := Array streamContents: [ :str |
        | generator |
        generator := Generator on: [ : g | Integer primesUpTo: 10000 do: [ :prime | g yield: prime ] ].
        [ generator atEnd ] whileFalse:[ str nextPut: generator next ] ].

list := SpListPresenter new 
    items: somePrimes;
    open;
    yourself.

list
    indexOf: 6619 
    ifAbsent: [ nil ].