Answers for "julia class"

0

julia class

# Julia does not have classes.
# The closest one can get to classes with methods in Julia is the module:

module DogClass
export Dog, bark

struct Dog
    name::String
end

function bark(d::Dog)
    println(d.name, " says woof!")
end

end #MODULE

using .DogClass  # note the . here, means look locally for module, not library

mydog = Dog("Fido")

bark(mydog)
Posted by: Guest on January-02-2021

Code answers related to "Julia"

Browse Popular Code Answers by Language