Templates for DRY code
codephantom
me at noyb.com
Sat Jan 6 02:14:41 UTC 2018
On Saturday, 6 January 2018 at 01:33:11 UTC, Ali Çehreli wrote:
> One solution is to wrap ~= in a function template. Now the
> conversion is automatically made to the element type of the
> array:
> ...
> .....
> I think append() could be a part of std.array but I can't find
> anything like that in Phobos.
>
> Ali
The problem with this, in my opinion, is that your template
'append' is doing a conversion behind the scenes..ie. I wouldn't
know that 'append' actually means 'convert & then append'.
When I read:
double[] a;
string s = "1.2";
a.append(s);
I think to myself...wtf is going on here? How can you append a
string to an array of doubles?
That's when I'd have go and find the append template and work out
what it is really doing.
More information about the Digitalmars-d-learn
mailing list