is_float

  • We can check if a variable is a float in Ruby using Object#is_a?.

    PHP

    $number = 1.2;
    $result = is_float($number);
    var_export($result);
    // => true

    Ruby

    number = 1.2
    p number.is_a?(Float)
    # => true

    see also

is_file is_int

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.