Aug-11-2018, 09:35 AM
(Aug-11-2018, 02:05 AM)jfong Wrote: [ Why bring complexity into this situation when you have a simple soultion? The ListDict may be a cute design but is verbose here and creates extra obstacle to the user.
It actually doesn't bring any additional complexity from a caller's standpoint. They never even know it's a not a dictionary or a list. If the caller specifies a key, then the return values act like a dictionary. If no keys are specified, it acts like a list.
When printed, for example, it will print as either a list or a dict. When it comes to syntax, the code looks exactly the same for both the user wishing for a list and for the user wanting to use a dict. Try out the latest version on GitHub and you'll see what I mean. Try to ignore the implementation detail and instead focus on the syntax.