I'm defining a function with two methods as follows:

a = 2.
b = 0.8

function u(c::Float64, h::Float64, b=b, a=a)
    ((c/(h^b))^(1-a))/(1-a)
end

function u(c::Float64, a=a)
     c^(1-a)/(1-a)
end

However, when calling u(2.), the result is -0.87..., which should be the 
result of the function call u(2., 2.). 
Clearly I misunderstand how multiple dispatch is working here - I thought 
when defining a function f() with one method f(::Float64), and another 
method f(::Float64, ::Float64), the two-argument version would only be 
called if I'm actually supplying two arguments!?

Reply via email to