is_object

  • Interrogating to check if a variable is an object in Ruby is pointless since everything is an object in Ruby. We can check if something is an object using Object#is_a?(Object), but this will always return true in Ruby.

    PHP

    $car = new stdClass;
    $result = is_object($car);
    var_export($result);
    // => true

    Ruby

    true.is_a?(Object)    # => true
    'hello'.is_a?(Object) # => true
    1.234.is_a?(Object)   # => true

    see also

Looking for Rails or PHP web application development, integration, and training?

Rails for PHP is brought to you by Maintainable Software. Get custom web applications and personalized training from the authors of the book and website.