On Mon, Sep 21, 2015 at 8:53 AM, Jon Norberg <[email protected]> wrote: > leaftype?
http://julia.readthedocs.org/en/latest/stdlib/base/?highlight=leaftype#Base.isleaftype http://julia.readthedocs.org/en/latest/manual/performance-tips/#code-warntype > > On Monday, September 21, 2015 at 2:41:02 PM UTC+2, Yichao Yu wrote: >> >> On Mon, Sep 21, 2015 at 8:37 AM, Jon Norberg <[email protected]> >> wrote: >> > quick question: How do I define a type most effective so that I can give >> > it both single values, vectors and Arrays as variables? >> > >> > I now have: >> > >> > type x >> > value::Array{Float64} >> > end >> > >> > I can do x(rand(3)) as well as x(rand(3,3)) but not x(0.1) >> >> Depends on what you need. If you don't need the field to be a leaftype >> (as in your code above), Union should work fine. >> >> > >> > the answer is probably in the forums but I couldn't construct a good >> > search to find it :-/ >> > >> > Thanks
