To get a 3 dimensional array using the syntax Stefan described, you need to tell it the number of indices along each dimesion. Eg `Array(Int, 3, 4, 5)` produces a 3x4x5 array
On Friday, December 19, 2014 7:29:50 PM UTC+13, [email protected] wrote: > > On Thursday, December 18, 2014 5:33:11 PM UTC-5, Steve Cordwell wrote: >> >> >> Hi John, >> >> `help(Array)` is telling you to use Array(SomeType, some_num_of_dims). If >> it was telling you about the type it would look more like this: >> >> > help(Int) >> DataType : >> Int64 >> >> >> supertype: Signed >> >> The `Base.Array(type, dims)` line at the top of the help is giving you >> the calling signature. Since Array is both the type name and a method to >> construct arrays, it can be used with both {} and (). >> > > Ah, both! I see. Also, I see that I can call `help()` on both types *and* > methods, but since "Array" is both, `help()` has to pick one, and I get the > Array *method* help text. > > Still though, the example Stefan posted above doesn't look like it makes > sense to me. He wrote: > > > > If you want to construct an uninitialized three value Int array, you > can do this: > > > > > > v = Array(Int, 3) > > but `help(Array)` says I'm supposed to pass in "dims"; I'd assumed this > means the same thing as what `ndims` returns --- i.e., 1D (Vector), 2D > (Matrix), etc. But calling `Array(Int, 3)` returns a *1D* array, rather > than 3D. Am I misreading the docs for Base.Array()? > > Try this: >> >> > typeof(Array{Int, 3}) >> DataType >> >> > typeof(Array(Int, 3)) >> Array{Int64,1} >> >> > typeof([1, 2, 3]) >> Array{Int64,1} >> >> > Ok. The object I get back `Array(Int64, 3)` is of exactly the same type as > the one I get back from `[1, 2, 3]` (though of course the latter comes with > garbage values in it as Stefan noted.) I can `push!()` to both of them. > > I also see that `Array` is an abstract (non-leaf) type, whereas > `Array{Int, 3}` is a concrete type: > > ~~~ > julia> isleaftype(Array) > false > > julia> isleaftype(Array{Int, 3}) > true > ~~~ > > Thanks! > > -- John > >
