how to write own defined function that includes an imported function?

Viewed 48

I am learning Julia programming by reading the book Think Julia I am including the following:

enter image description here

forward is a function in the ThinkJulia module. It acts on the Turtle() object, to move it forward. Why, after the line using ThinkJulia , am I getting this error. Do I have to be more specific in Julia about importing functions? I thought using would give me access to all functions in that particular module?

2 Answers

You need to pass a value not to its type to forward, so define your function like this:

function forward_len(t::Turtle, d)
    forward(t, d)
end

and things should work

Related