Last active
April 22, 2019 04:06
-
-
Save Iainmon/249e37bf37540ff67594b1c3d9ebd7ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class Animal | |
abstract def speak | |
end | |
class Dog < Animal | |
def speak | |
"Bark!" | |
end | |
end | |
class Cat < Animal | |
def speak | |
"Meow!" | |
end | |
end | |
def printSpeak(animal : Animal) | |
puts animal.speak | |
end | |
dog = Dog.new | |
cat = Cat.new | |
printSpeak(cat) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment