gdritter repos collage / master examples / structural-types / crystal-source / src / crystal-source.cr
master

Tree @master (Download .tar.gz)

crystal-source.cr @master

d56e06d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
# «program»
class Cat
  def speak() puts "meow" end
end

class Cow
  def speak() puts "moo" end
  def num_stomachs() 4 end
end

def hear_what_it_has_to_say(obj)
  obj.speak
end

hear_what_it_has_to_say(Cat.new)
hear_what_it_has_to_say(Cow.new)
# «end»