Simplest way I can think of:
# checking whether foo is a boolean
!!foo == foo
More Related Contents:
- Ruby syntax error, unexpected tIDENTIFIER, expecting end-of-input
- Ruby: String Comparison Issues
- Ruby 2.0.0p0 IRB warning: “DL is deprecated, please use Fiddle”
- Ruby metaclass confusion
- What are all the common ways to read a file in Ruby?
- What exactly is `&:capitalize` in Ruby?
- Difference between map and collect in Ruby?
- How do I get the match data for all occurrences of a Ruby regular expression in a string?
- What does __FILE__ mean in Ruby?
- Why isn’t the eigenclass equivalent to self.class, when it looks so similar?
- Ruby Hash with duplicate keys?
- Performance of Arrays and Hashes in Ruby
- Installing Jekyll without root
- Does Ruby perform Tail Call Optimization?
- In Ruby, is there an Array method that combines ‘select’ and ‘map’?
- Running a command from Ruby displaying and capturing the output
- In Rails, how to add a new method to String class?
- Why isn’t self always needed in ruby / rails / activerecord?
- What does “
- Chrome 62 and Flash
- What does the equal (‘=’) symbol do when put after the method name in a method definition?
- Why does “compass watch” say it cannot load sass/script/node (LoadError)?
- When to use `require`, `load` or `autoload` in Ruby?
- Natural Language Processing in Ruby [closed]
- How can I get the absolute URL when extracting links using Nokogiri?
- In Ruby why won’t `foo = true unless defined?(foo)` make the assignment?
- How to determine if a character is a Chinese character
- What does the unary question mark (?) operator do?
- What is the behavior when using both positional and keyword arguments in Ruby?
- Should I use alias or alias_method?