`similar` does what you're looking for: ``` similar(array, [element_type=eltype(array)], [dims=size(array)])
Create an uninitialized mutable array with the given element type and size, based upon the given source array. ``` Note that this puts the burden onto the creator of the type. On Wed, 2016-02-10 at 20:20, Yichao Yu <[email protected]> wrote: > On Wed, Feb 10, 2016 at 2:13 PM, Josh Langsfeld <[email protected]> wrote: >> Yeah, it does seem ill-posed in general. Still, it would nice if I could do >> this for at least some subtypes that use the same type parameter pattern, >> even if the behavior was undefined when it doesn't use the same pattern. >> >> Is there any method of dynamically computing a new type by changing one of >> the parameters of a type known only at runtime? >> >> On Wednesday, February 10, 2016 at 1:04:14 PM UTC-5, Lutfullah Tomak wrote: >>> >>> For AbstractArray, a caveat is the actual type may have more parameters >>> and cannot be sure about parameters' order. > > You can always get the parameters (.parameters field) and construct a new > type. Does this always work? Types can define their constructors as they wish? For instance: julia> Array{Int,3}() ERROR: MethodError:....
