June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
20
Task/Classes/Julia/classes.julia
Normal file
20
Task/Classes/Julia/classes.julia
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
abstract type Mammal end
|
||||
habitat(::Mammal) = "planet Earth"
|
||||
|
||||
struct Whale <: Mammal
|
||||
mass::Float64
|
||||
habitat::String
|
||||
end
|
||||
Base.show(io::IO, ::Whale) = print(io, "a whale")
|
||||
habitat(w::Whale) = w.habitat
|
||||
|
||||
struct Wolf <: Mammal
|
||||
mass::Float64
|
||||
end
|
||||
Base.show(io::IO, ::Wolf) = print(io, "a wolf")
|
||||
|
||||
arr = [Whale(1000, "ocean"), Wolf(50)]
|
||||
println("Type of $arr is ", typeof(arr))
|
||||
for a in arr
|
||||
println("Habitat of $a: ", habitat(a))
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue