Skip to content

Instantly share code, notes, and snippets.

@revskill10
Last active January 27, 2023 21:15
Show Gist options
  • Save revskill10/2e065f6ae753e528e466f7e9702b5b39 to your computer and use it in GitHub Desktop.
Save revskill10/2e065f6ae753e528e466f7e9702b5b39 to your computer and use it in GitHub Desktop.
Pipeline programming
class Object
def true?
return unless self
tmp = yield
return tmp
end
def else
return yield unless self
self
end
end
(1 + 1 == 3).true? { [3,4,5] }
.else { [1,2] }
.filter{ |item| (item % 2 == 0) }
.each { |item| puts "ITEM #{item}" }
# print 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment