On Fri, May 29, 2015 at 3:50 PM, Seth <[email protected]> wrote:
> I have an function that takes an optional (potentially very large) matrix
> (AbstractArray{Float64,2}). I'd like to create a parameter to the function
> that's EITHER this array, or a boolean (false). If I define
>
> edge_dists::Union(Bool, AbstractArray{Float64,2}) = false
>
>
>
> in my function declaration, would that cause significant performance
> penalties when accessing the parameter?
The function will specialize on (the type of) this parameter so there
shouldn't be a big penalty. If you need to do something different when
this parameter is missing and if the two cases shares a lot of code,
this might not be a bad idea (although IMHO ::Union(Void,
AbstractArray{Float64, 2})=nothing might be more intuitive)