PHP to Ruby
Convert PHP code into Ruby!
-
is_object
Posted on August 15th, 2009 No commentsThe is_object() function allows you to check if a particular variable is an object.
PHP
$obj = new stdClass(); var_dump( is_object($obj) ); // => true
In Ruby we can check if a variable is an object by using the Object#is_a? method - however this will always return true as with Ruby everything (almost) is an object.
Ruby
puts "Hello World".is_a?(Object); # => true


