Skip to content

Instantly share code, notes, and snippets.

View cesargralmeida's full-sized avatar

César Almeida cesargralmeida

View GitHub Profile
@cesargralmeida
cesargralmeida / descending.md
Last active February 12, 2019 21:58
Codewars my solutions
@cesargralmeida
cesargralmeida / rock_that_swims.rb
Last active February 7, 2019 14:16
rock_that_swims.rb
class Rock
def method_missing(m, *args, &block)
if m == :swim
puts 'Learning how to swim'
self.create_method(:swim) { 'Sinks quickly' }
end
end
def create_method(name, &block)
self.class.send(:define_method, name, &block)
end
class Duck
def quack
'Quack!'
end
def swim
'Quack paddle and quack and paddle...'
end
end
class Duck
def quack
'Quack!'
end
def swim
'Paddle paddle paddle...'
end
end
@cesargralmeida
cesargralmeida / duck_typing.rb
Last active February 7, 2019 13:10
Duck typing code
class DomesticDuck
def quack
'Quack!'
end
def swim
'Paddle paddle paddle...'
end
end