Re: Initialize static array without explicit length

2018-12-03 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 3 December 2018 at 12:19:26 UTC, Dennis wrote: On Monday, 3 December 2018 at 10:00:31 UTC, Simen Kjærås wrote: However, it's easy to implement in a library: It even is in phobos: https://dlang.org/phobos/std_array.html#.staticArray ``` import std.array: staticArray; auto a = [0, 1,

Re: Initialize static array without explicit length

2018-12-03 Thread Dennis via Digitalmars-d-learn
On Monday, 3 December 2018 at 10:00:31 UTC, Simen Kjærås wrote: However, it's easy to implement in a library: It even is in phobos: https://dlang.org/phobos/std_array.html#.staticArray ``` import std.array: staticArray; auto a = [0, 1, 2].staticArray; ```

Re: Initialize static array without explicit length

2018-12-03 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 3 December 2018 at 09:51:45 UTC, Andrey wrote: Hi, I want to create a static array and immediately init it with values: uint[x] data = [1,3,10,44,0,5000]; I don't want to set the length of it explicitly (x in square brackets). I want that compiler itself counted number of

Initialize static array without explicit length

2018-12-03 Thread Andrey via Digitalmars-d-learn
Hi, I want to create a static array and immediately init it with values: uint[x] data = [1,3,10,44,0,5000]; I don't want to set the length of it explicitly (x in square brackets). I want that compiler itself counted number of values (in example it is 6). What should be a right synt