Last active
October 20, 2022 15:28
-
-
Save joeldrapper/e2f1eb8fab8f28caf4460b576e0fb41e to your computer and use it in GitHub Desktop.
Object yielders
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 Object | |
def then_maybe | |
yield(self) || self | |
end | |
def then_if(condition) | |
condition ? yield(self) : self | |
end | |
def then_unless(condition) | |
!condition ? yield(self) : self | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was thinking of it as a blank
case
statement like:But true, it can be confusing.