Type redefinition in Julia: incorrect constant redefinition

Suppose I assigned the type Person to 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 be displayed using the function:

 Name: Ted Male: true Age: 55.0 Children: 0 

Then I change the functions for type Person , where I added a new category to 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 get around this when developing new code? besides creating a module as suggested in julia Frequently Asked Questions

+8
types oop julia-lang
source share
1 answer

You can use workspace () to clear the Main module if you do not want to enter the code yourself on the module.

+9
source share

All Articles