This works:
type Dude
say_something::Function
# constructor
function Dude()
dude = new()
dude.say_something = function(what::AbstractString)
print(what)
end
return dude
end
end
dude = Dude()
dude.say_something("hi")
But I want a default argument for what. However, this code:
type Dude
say_something::Function
# constructor
function Dude()
dude = new()
dude.say_something = function(what::AbstractString="hi")
print(what)
end
return dude
end
end
dude = Dude()
dude.say_something("hello")
yields an error:
ERROR: LoadError: syntax: expected "(" in function definition
in include at ./boot.jl:261
in include_from_node1 at ./loading.jl:304
in process_options at ./client.jl:280
in _start at ./client.jl:378
Are default arguments or keyword arguments not allowed in a Function attribute of a type?