Hello all, I had a question concerning a best practice in a particular case 
of multiple dispatch which is as follows.

Let's say I have a function with two different methods.

function my_func(fcn1::Function,fcn2::Function, passedIn::Float64)
 x = 0.0
 y = 1.0
 z = 2.0
 val1 = fcn(x, y, passedIn)
 val2 = fcn2(y, z, passedIn)
 return val1, val2
end

function my_func(fcn1::Function, passedIn::Float64)
 x = 0.0
 y = 1.0
 z = 2.0
 val1 = fcn(x, y, passedIn)
 val2 = default_fcn(x, y, z, passedIn)
 return val1, val2
end

My question is basically, what would be the best way to do this without 
massive code duplication?  The actual situation I am working with has much 
more going on in the function, so it's not like I could create some init 
function to set up x, y, & z.  But literally the only different behavior 
between the two methods is whether or not a second function is passed in.

Thanks!

Chris

Reply via email to