Re: multi-dimensional array whole slicing

2017-04-25 Thread XavierAP via Digitalmars-d-learn
On Tuesday, 25 April 2017 at 20:46:24 UTC, Ali Çehreli wrote: I think it's still consistent because the element type is not int in the case of multi-dimensional arrays. [...] int[3][4] b; b[] = [1, 1, 1]; It is consistent, I just miss the possibility to more easily initialize

Re: multi-dimensional array whole slicing

2017-04-25 Thread Ali Çehreli via Digitalmars-d-learn
On 04/23/2017 12:04 PM, XavierAP wrote: > For both multi-dimensional and > uni-dimensional arrays a[] and a[][] are the same. And yet, a[] has > different type in both cases and a[]=1 compiles for uni-dimensional but > not for multi-dimensional. I think it's still consistent because the element

Re: multi-dimensional array whole slicing

2017-04-23 Thread XavierAP via Digitalmars-d-learn
On Sunday, 23 April 2017 at 09:06:35 UTC, Ali Çehreli wrote: It took me a while to convince myself that there is no bug here. The problem, as is obvious to others, ;) a whole slice of a whole slice is still the same slice. Ha, you're right, I hadn't realized. But I still have a problem.

Re: multi-dimensional array whole slicing

2017-04-23 Thread Ali Çehreli via Digitalmars-d-learn
On 04/22/2017 01:51 PM, XavierAP wrote: > I can do: > > int[3] arr = void; > arr[] = 1; > > But apparently I can't do: > > int[3][4] arr = void; > arr[][] = 1; > > What is the best way? What am I missing? It took me a while to convince myself that there is no bug here. The problem, as is

Re: multi-dimensional array whole slicing

2017-04-23 Thread XavierAP via Digitalmars-d-learn
On Saturday, 22 April 2017 at 22:25:58 UTC, kinke wrote: int[3][4] arr = void; (cast(int[]) arr)[] = 1; assert(arr[3][2] == 1); Thanks... I think I prefer to write two loops though :p I wish D built-in arrays supported [,] indexing notation like C# (or as you can do in D for custom types)

Re: multi-dimensional array whole slicing

2017-04-22 Thread kinke via Digitalmars-d-learn
On Saturday, 22 April 2017 at 20:51:46 UTC, XavierAP wrote: I can do: int[3] arr = void; arr[] = 1; But apparently I can't do: int[3][4] arr = void; arr[][] = 1; What is the best way? What am I missing? int[3][4] arr = void; (cast(int[]) arr)[] = 1; assert(arr[3][2] == 1);

multi-dimensional array whole slicing

2017-04-22 Thread XavierAP via Digitalmars-d-learn
I can do: int[3] arr = void; arr[] = 1; But apparently I can't do: int[3][4] arr = void; arr[][] = 1; What is the best way? What am I missing?