[Issue 10635] Error: cannot use array to initialize S

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 21 04:12:30 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=10635



--- Comment #3 from Daniel Kozak <kozzi11 at gmail.com> 2013-11-21 04:12:29 PST ---
(In reply to comment #2)
> (In reply to comment #1)
> > Now neither work.
> 
> No it is same as before, but my example was bad. I mean this:
> 
> struct S {
>     string str;
>     static S opCall(string[] v) {
>         S s;
>         s.str = v[0];
>         return s; 
>     }
>     static S opCall(string[string] v) {
>         S s;
>         s.str = v.keys[0];
>         return s; 
>     }
> }
> 
> void main(string[] args) {
>     S s1 = ["getnonce"]; // this works
>     S s = ["getnonce" : "str"]; // this doesnt work
> }

void main(string[] args) {
    S s1 = S(["getnonce"]); // this works
    S s2 = ["getnonce"]; // this works
    S s3 = S(["getnonce" : "str"]); // this works
    S s4 = ["getnonce" : "str"]; // this doesnt work but shoud be same as s3
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list