It's not really inherited from C (where it is the result of a confusing feature called array/pointer decay), it's a generalization of Julia's multidimensional array support, where trailing dimensions are assumed to be 1, so that x[] === x[1] === x[1, 1, 1, 1, 1, ...]
On Sun, Sep 20, 2015 at 1:07 PM Sisyphuss <[email protected]> wrote: > If you are familiar with C, an array is nothing else than a pointer > pointing the first element of an array. > > So `x[0]` is the first element (C is 0-based), `x[1]` is just the pointer > moving forward by 1 unit. > `x[]` has the same meaning as `x[0]`. > > Obviously, Julia inherits this convention. > > > > On Saturday, September 19, 2015 at 7:42:57 PM UTC+2, Ismael VC wrote: >> >> I would have expected an error. >> >> Julia: >> >> julia> VERSION >> v"0.4.0-rc1" >> >> julia> x = [1:5;]; >> >> julia> x[], x[1] >> (1,1) >> >> Python: >> >> >>> x = range(1, 6) >> >>> x[] >> File "<stdin>", line 1 >> x[] >> ^ >> SyntaxError: invalid syntax >> >> >>
