Returns a boolean based on the given argument.
Add this line to your application's Gemfile:
gem "kernel-boolean"
And then execute:
bundle install
Or install it yourself as:
gem install kernel-boolean
If the argument is true
, returns true
.
If the argument is false
, returns false
.
In all other cases, returns an error.
require "kernel/boolean"
Boolean(false) # => false
Boolean(true) # => true
Boolean(nil) # => TypeError: can't convert nil into boolean
Boolean("true") # => ArgumentError: invalid value for Boolean(): "true"
The #Boolean
method could be used similarly to the methods already present in the Kernel
module:
#Array
#Complex
#Float
#Hash
#Integer
#Rational
#String
The Kernel
module is included in the Object
class, so by loading this library, the #Boolean
method will be available in every Ruby object.
Kernel#Boolean
uses Semantic Versioning 2.0.0
kernel-symbol
: Returns aSymbol
based on the given argument.
The gem is available as open source under the terms of the MIT License.