Skip to content

Instantly share code, notes, and snippets.

@rafaelss
Forked from tinogomes/gist:1006296
Created June 3, 2011 13:13
Show Gist options
  • Save rafaelss/1006315 to your computer and use it in GitHub Desktop.
Save rafaelss/1006315 to your computer and use it in GitHub Desktop.
.boolean? method for ruby objects
module RubyExt
module Boolean
def bool?
[ true, false ].include?(self)
end
end
end
::Object.__send__ :include, RubyExt::Boolean
@rafaelss
Copy link
Author

rafaelss commented Jun 3, 2011

ruby-1.9.2-p180 :012 > FalseClass.bool?
 => false 
ruby-1.9.2-p180 :013 > TrueClass.bool?
 => false 

é, não testei com essas duas :D

@tinogomes
Copy link

pois é

;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment