On Mon, Feb 22, 2016 at 1:51 PM, Martin Kuzma <[email protected]> wrote: > Let's say that i have a type T with array field like this: > > type T > x::Array{Int}
You can define `T() = new()` here to make T() works > end > > I want to implement lazy initialization for the array. > > o = T(Int[]) # Or better calling T(), but it raises exception > o.x # Initilizes the array and returns it. getfield currently can't be overwritten. You can use a function (e.g. getX(::T)) instead now. > > > I think this should be possible by overloading getfield function, but i > don't exactly know how to do that. Is this possiblle in julia? >
