Momentary Eh?! for a Dynamic Language Programmmer. Tuples vs Arrays. Just rambling.

John Carter via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 23 14:18:38 PDT 2014


I guess between perl and Ruby and Scheme etc. I got used to 
creating hybrid containers....

Want a pair of [string, fileList]? Just make an Array with two 
items, one a string, one and array of strings. Done.

D barfed... leaving me momentarily stunned... then Oh Yes, type 
safety, Tuple's are the answer where Tuples where Tuples...

Eventually found http://dlang.org/tuple.html and more 
specifically the somewhat unexpectedly named 
http://dlang.org/phobos/std_typecons.html and off I went...

I do have a personal design guideline of when you adding too much 
behaviour to a heterocontainer, refactor into a class.

But I guess I have never realised how often I do casually create 
heterogenous containers....

Just rambling and musing.


More information about the Digitalmars-d-learn mailing list