This file contains hidden or 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 | |
# Usage: | |
# maybe_zero.self_unless(&:zero?) || zero_fallback | |
# # => either maybe_zero or zero_fallback (if maybe_zero was zero) | |
def self_unless | |
self unless yield(self) | |
end | |
# Usage: | |
# maybe_present.self_if(&:present?) |