Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

ruby is variable boolean

# Simplest way to check if foo is a boolean
!!foo == foo

# Concise and self-documenting
[true, false].include? foo

# When using Rails or ActiveSupport, also self-documenting
foo.in? [true, false]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #ruby #variable #boolean
ADD COMMENT
Topic
Name
9+7 =