Lets say I assign a type Person
in Julia:
type Person
name::String
male::Bool
age::Float64
children::Int
end
function describe(p::Person)
println("Name: ", p.name, " Male: ", p.male)
println("Age: ", p.age, " Children: ", p.children)
end
ted = Person("Ted",1,55,0)
describe(ted)
Which will output with the function:
Name: Ted Male: true
Age: 55.0 Children: 0
Then I modify the features for type Person
where I added a new category to the type eyes
type Person
name::String
male::Bool
age::Float64
children::Int
eyes::String
end
ted = Person("Ted",1,55,0,brown)
If I run the function now I get an error
Error evaluating REPL:
invalid redefinition of constant Person
in include_string at loading.jl:97
What is the best way to work around this when developing new code? other than making a module as suggested in the julia FAQ
You can use the workspace() function to clear the Main
module if you don't want to put the code in its own module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With