Convert PHP code into Ruby!
RSS icon Email icon Home icon
  • is_bool

    Posted on August 1st, 2009 RubyLove No comments

    The is_bool() function allows you to check if a particular variable is a boolean (type).

    PHP

    $my_variable = 1;
    var_dump( is_bool($my_variable) );
    // => false

    Ruby

     my_variable = 1;
    puts my_variable.is_a?(FalseClass) || my_variable.is_a?(TrueClass)
    # => false