3
Reply

Collection with multiple keys

Rob

Rob

Jun 3 2008 3:55 AM
10.7k
Hi,

I've seen collections where elements can be accessed using different 'keys' or accessors in an overloaded array sort of way. Let me show you what I mean:

MyCollection[3] would get the 4th object in the collection
MyCollection["title"] would get the object with a title of 'title'
MyCollection[SomeObj] would get the object with the matching SomeObj

I'm not sure how this is done; through some type of extended collection or using some type of interface. Does anyone have any simple examples of doing this? Or any suggestions on what I might be trying to do?

Many thanks,

Rob

Answers (3)