Skip to content

Instantly share code, notes, and snippets.

@lbvf50mobile
Last active February 11, 2017 05:45
Show Gist options
  • Save lbvf50mobile/d7f0ca6099bf6da7b09d0a41106e9592 to your computer and use it in GitHub Desktop.
Save lbvf50mobile/d7f0ca6099bf6da7b09d0a41106e9592 to your computer and use it in GitHub Desktop.
if_else using messages and objects
class TrueClass
def is_true
yield
self
end
def is_false
self
end
end
class FalseClass
def is_true
self
end
def is_false
yield
self
end
end
puts "hi"
(1==1).is_true{ puts "yes"}
(1==3).is_false{puts "yes it false"}
[true,false].each{|i| (i).is_true{puts "this is true"}.is_false{puts "this is false"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment