Sorry, do this instead to make sure that the code is type stable:

+{S,T}(x::Nullable{S}, y::Nullable{T}) = isnull(x) || isnull(y) ? 
Nullable{promote_type(S,T)}() : Nullable(x.value + y.value)
+{S,T}(x::Nullable{S}, y::T) = +(x, Nullable(y))
+{S,T}(x::T, y::Nullable{S}) = +(y, x)

// T

On Tuesday, October 6, 2015 at 9:31:15 AM UTC+2, Tomas Lycken wrote:

It seems that you should be able to do this by defining new methods for the 
> operations you need to support. For addition, you could do
>
> ```
> +{S,T}(x::Nullable{S}, y::Nullable{T}) = isnull(x) || isnull(y) ? 
> Nullable{promote_type(S,T)}() : x.value + y.value
> +{S,T}(x::Nullable{S}, y::T) = +(x, Nullable(y))
> +{S,T}(x::T, y::Nullable{S}) = +(y, x)
> ```
>
> For other operations, you would do similar things.
>
> // T
>
>
> On Tuesday, October 6, 2015 at 4:33:05 AM UTC+2, [email protected] 
> wrote:
>>
>> I'd like to be able to do for example:
>>
>> Nullable(3.) + 6 = Nullable(9.)
>>
>> as well as
>>
>> Nullable(3.) + Nullable(6) = Nullable(9)
>>
>> All types interacting with Nullables -> Nullable
>>
>> ​

Reply via email to