Platinum Partner

Determine If A String Is Numeric In Ruby

# Determine if a string is numeric using Float and rescue
# Revised long version from http://rosettacode.org/wiki/Determine_if_a_string_is_numeric#Ruby


def numeric?(s)
  begin
    Float(s)
  rescue
    false # not numeric
  else
    true # numeric
  end
end
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}