www.digitalmars.com         C & C++   DMDScript  

D - lvalue to slice

Provided:
int i;
How about &i implicitly converts to type int[0 .. 1] ?

You could do this:

char[] foo(char ch)
{
    return "The character is: " ~ &ch; //instead of (&ch)[0 .. 1]
}

The compiler already knows how many elements it has, so why not? :)


-- 
Christopher E. Miller
Mar 19 2004