Does isdefined(:t) do what you want?

In matlab, isempty(t) also gives you an error if you've never defined a value 
for t.

--Tim

On Sunday, January 18, 2015 07:14:03 PM J Luis wrote:
> OK, I found that:
> 
> julia> try isempty(t) end
> false
> 
> julia> try isempty([]) end
> true
> 
> but this is uggly
> 
> segunda-feira, 19 de Janeiro de 2015 às 02:42:09 UTC, J Luis escreveu:
> > How do I test if a variable has something or if it's empty?
> > What I need is something that behaves like the Matalb's isempty()
> > 
> > Julia isempty() is no good because it only tests collections. e.g
> > 
> > julia> type foo a end
> > 
> > julia> t=foo(1)
> > foo(1)
> > 
> > julia> isempty(t)
> > ERROR: `start` has no method matching start(::foo)
> > 
> > isnan() is no good either for a similar reason
> > 
> > julia> isnan(t)
> > ERROR: `isnan` has no method matching isnan(::foo)
> > 
> > It's a petty that these two don't behave like in Matlab

Reply via email to