mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Merge pull request #454 from adrianlzt/feature/improve_defined_types_functions
[julia/en] Functions with defined types parameters a little bit confusing
This commit is contained in:
commit
0aa7e32f05
@ -575,15 +575,15 @@ end
|
|||||||
# For a non-constructor example, let's make a function meow:
|
# For a non-constructor example, let's make a function meow:
|
||||||
|
|
||||||
# Definitions for Lion, Panther, Tiger
|
# Definitions for Lion, Panther, Tiger
|
||||||
function meow(cat::Lion)
|
function meow(animal::Lion)
|
||||||
cat.roar # access type properties using dot notation
|
animal.roar # access type properties using dot notation
|
||||||
end
|
end
|
||||||
|
|
||||||
function meow(cat::Panther)
|
function meow(animal::Panther)
|
||||||
"grrr"
|
"grrr"
|
||||||
end
|
end
|
||||||
|
|
||||||
function meow(cat::Tiger)
|
function meow(animal::Tiger)
|
||||||
"rawwwr"
|
"rawwwr"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user