Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
class Object
# nil if false, else self
def only_if(&block)
self if self.instance_eval(&block)
end
end
puts ''.only_if { length > 0 } || 'previously blank'
# => 'previously blank'
puts 'not blank'.only_if { length > 0 } || 'previously blank'
# => 'not blank'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.