Last active
September 19, 2016 14:01
-
-
Save marcinwyszynski/e88f5d03617de6e68d6bb6efda2ddff0 to your computer and use it in GitHub Desktop.
Clever duplication trick
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
# frozen_string_literal: true | |
class Apple | |
def one | |
loop do | |
'kaboom' | |
.map { |char| char.upcase.downacase } | |
.filter { |char| char != '0' } | |
.drop { |char| char == 7 } | |
end | |
end | |
end # class Apple |
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
# frozen_string_literal: true | |
class Banana | |
has_one :monkey | |
def one | |
loop do | |
'kaboom' | |
.map { |char| char.upcase.downacase } | |
.filter { |char| char != '0' } | |
.drop { |char| char == 7 } | |
end | |
end | |
end # class Banana |
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
# frozen_string_literal: true | |
class Cherry | |
has_one :starling | |
def one | |
loop do | |
'kaboom' | |
.map { |char| char.upcase.cherrify } | |
.hello { |char| char != '0' } | |
.drop { |char| char == 7 } | |
end | |
end | |
end # class Cherry |
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
class Dog | |
def annoy | |
loop do | |
loop do | |
loop do | |
loop do | |
puts 'woof!' | |
end | |
end | |
end | |
end | |
end | |
def annoy_more | |
apples.each do |apple| | |
apple.bananas.each do |banana| | |
banana.cherries.each do |cherry| | |
cherry.bites do |bite| | |
bite.chew | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment