isdefined(myobject, :myfield)

On Tuesday, July 22, 2014 6:54:00 PM UTC-4, Ben Ward wrote:
>
> I have a type that contains references to other instances of the same type 
> - like a doubly linked list or - as it's intended use, like a tree like 
> structure. They contain references to a parent of the same types and an 
> array of references to children of the same type. However a root or singly 
> constructed instance of the type will not start out with a parent or 
> children and so these fields will be #undef, how can I check for #undef 
> fields? It didn't say in the types section in the manual, although it did 
> say accessing it is an automatic error so I guess a try block might work - 
> but I don't know if try blocks are preferable in Julia to simply 
> anticipating the #undef. I've normally heard the mantra of anticipating an 
> expected exception rather than make excessive try catches.
>
> Thanks. 
>

Reply via email to