Why this defensive approach to code that adds duplicate entries to a menu? Why not avoid the duplicated entries from being added to begin with? On 5/20/11 2:58 , Bernat Romagosa wrote:
You may want the collection from which you build a menu to be a Set because you don't want to have repeated entries in a menu, and you'd want nil to be there if your field can be empty. When the menu items are automatically generated, it'd be nice to be able to do Whatever buildMenuFrom: (myCollection asSet add: nil; yourself).
IMO this would be more elegant than doing myCollection asSet asOrderedCollection add: nil; yourself, or any other way to ensure the elements are unique and the collection includes nil.
2011/5/20 Henrik Sperre Johansen <henrik.s.johansen@veloxit.no <mailto:henrik.s.johansen@veloxit.no>>
On 20.05.2011 11:36, Bernat Romagosa wrote:
On a dropdown menu where you can choose between 'apple' -> #apple, 'orange' -> #orange or 'nothing' -> nil, for example :)
Huh? How does a Set figure into that?
Cheers, Henry