Just trying to get my head around Julia and came across the need where a type member should be of a particular type or it can also be nothing
. So, I tried the following:
using NIfTI # Julia package for reading NIfTI medical images
type RR
source::Union(NIfTI.NIVolume, nothing)
end
However, when I try to initialize this object, I get:
ERROR: LoadError: LoadError: MethodError: no method matching Union(::Type{NIfTI.NIVolume}, ::Void)
The reason I want to do this is that there is no good default way to initialize the NIVolume
object and it seems a good idea to leave it uninitialized till needed.
Nullable
type in julia. – GnimucNIfTI.jl
provides a default way to initNIVolume
. – Gnimucoptional or keyword arguments
, so you can simply init a nii object viaNIVolume()
orNIVolume(rand(3,3,3), descrip="my nii obj")
(the first optional argument is the raw data;descrip
is keyword argument.) – Gnimuc