On 4/19/14, matovitch via Digitalmars-d-learn
<digitalmars-d-learn@puremagic.com> wrote:
> This won't compile :
>
> import std.stdio;
>
> void main()
> {
>       Test t;
>       t.data = [152, 32, 64, 28, 95];
>       float b = t.get;
>       writefln("%s", b);
> }

Because it's probably overkill. At some point it becomes too much
magic. The following currently works but it might be considered an
ambiguity with return type inference:

-----
struct S
{
    int get()  { return 0; }
    T get(T)() { return T.init; }
}

void main()
{
    S s;
    float x = s.get();  // which overload? (currently int get())
}
-----

Reply via email to