I see now. I thought 0-dimensional arrays could not contain any element at
all.
For consistency, wouldn't it be better to thrown an error when myArray[] is
used for non-zero-dimensional arrays?
Looks like a difficult to find typo.
--
Carlos
On Fri, May 3
On Friday, May 30, 2014 5:19:35 PM UTC-4, Carlos Becker wrote:
>
> HI Jacob,
>
> I get that, but which is the reasoning behind myArray[] ?
> why should it return a ref to the 1st element?
>
Because you can have a 0-dimensional array, and a 0-dimensional array
contains exactly 1 element (the em
HI Jacob,
I get that, but which is the reasoning behind myArray[] ?
why should it return a ref to the 1st element?
--
Carlos
On Fri, May 30, 2014 at 11:09 PM, Jacob Quinn
wrote:
> a[] is rewritten as `getindex(a)`, which has a definition in array.jl#
a[] is rewritten as `getindex(a)`, which has a definition in array.jl#244
getindex(a::Array) = arrayref(a,1)
-Jacob
On Fri, May 30, 2014 at 5:05 PM, Carlos Becker
wrote:
> My apologies if this is something that was addressed before, I didn't find
> it.
>
> Why does myArray[] return the first
My apologies if this is something that was addressed before, I didn't find
it.
Why does myArray[] return the first element of the array? is there a
reasoning behind it or is it an 'unexpected language feature'?
For example:
a = [1,2,3,4]
a[] => returns 1
Thanks.