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
Main
module more in line with what you are looking for? – Toivo Henningsson