On Fri, May 29, 2015 at 9:21 AM, andrew cooke <[email protected]> wrote:
>
> Ahh!
>
> No, its possible:
>
>
> julia> foo(::Nullable{Union()}) = "empty"
> foo (generic function with 1 method)
>
> julia> foo(::Nullable{Int}) = "int"
> foo (generic function with 2 methods)
>
> julia> foo(Nullable())
> "empty"
>
> julia> foo(Nullable(4))
> "int"

I'm not sure if this is what you want.

The point of Nullable is that it maintains type stability when you
return "missing value", i.e. the type of a Nullable you should get
from a function should always be the same (otherwise there's no point
to use Nullable to begin with). In a function that returns Int or a
missing value, you return either Nullable(<int value>) or
Nullable{Int}().

Unfortunately, this means that you cannot dispatch on the type (since
there's only one and that's the point). IMHO, depending on your
usecase, you might be better off branching on whether the Nullable has
a value.

>
>
> Sorry, please ignore!

Reply via email to