resizeable arrays: T[new]

Reiner Pope some at address.com
Thu Jun 7 00:15:02 PDT 2007


Reiner Pope wrote:
> I'm not sure what the suggested rewrite of this would be. 
Actually, it would make more sense to template it:

> char[new=IsNew] withDecimals(bool IsNew)(char[new=IsNew] num)
> {
>     foreach (i, c; num)
>         if (c == '.')
>             return num;
> 
>     char[new] newNum;
>     static if (IsNew)
>         newNum = num;
>     else
>         newNum = num.dup;
> 
>     newNum ~= ".0";
>     return newNum;
> }


   -- Reiner



More information about the Digitalmars-d-announce mailing list