yes, that works perfectly. thanks!

On Sat, Mar 8, 2014 at 11:51 AM, Andreas Noack Jensen
<[email protected]> wrote:
> You can make an empty array of your type with
>
> julia> MyType[]
> 0-element Array{MyType,1}
>
> Would that work for you?
>
>
> 2014-03-08 20:44 GMT+01:00 Madeleine Udell <[email protected]>:
>
>>
>> Hi,
>>
>> I'd like to allow a function to take arguments that consist of arrays of a
>> type I've defined, or empty arrays. In many languages, one can do this using
>> option types; is there an analogue in julia?
>>
>> Concretely, I'd like to define T so that the last typeassert here will be
>> true:
>>
>> julia> type MyType
>>            value
>>        end
>>
>> julia> T=Union(MyType,None)
>> MyType (constructor with 1 method)
>>
>> julia> [MyType(4)]::Array{T}
>> 1-element Array{MyType,1}:
>>  MyType(4)
>>
>> julia> []::Array{T}
>> ERROR: type: typeassert: expected Array{MyType,N}, got Array{None,1}
>>
>> Thanks!
>> Madeleine
>
>
>
>
> --
> Med venlig hilsen
>
> Andreas Noack Jensen



-- 
Madeleine Udell
PhD Candidate in Computational and Mathematical Engineering
Stanford University
www.stanford.edu/~udell

Reply via email to