[Issue 8008] static array literal syntax request: auto x=[1,2,3]S;

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 31 10:27:11 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=8008


Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich at gmail.com


--- Comment #4 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-05-31 10:27:09 PDT ---
(In reply to comment #0)
>  * no easy way to pass a static array literal to a function accepting a static
> array; for example it requires:
>    int[3] x=[1,2,3]; 
>    fun(x);

That can't be true. This works fine:

-----
void fun(int[3] arr) { }

void main()
{
    fun([1, 2, 3]);
}
-----

I've tried it with 2.050, and it worked there.

Additionally since 2.063 you can also do:

-----
void fun(int[3] arr) { }

void main()
{
    auto x = [1, 2, 3];
    fun(x[0 .. 3]);
}
-----

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


More information about the Digitalmars-d-bugs mailing list