Would love to see a typecasting method to allow for values like 4.5, 6, true, false, etc
Here is a method that I use for simple typecasting:
def typecast(value)
case value
when /^\s*$/ then nil
when /^-?(?:\d|[1-9]\d+)$/ then Integer(value)
when /^-?(?:\d|[1-9]\d+)(?:\.\d+)?(?:e[+-]?\d+)?$/i then Float(value)
when /true/i then true
when /false/i then false
else value
end
end
This isn't a bug but more of a feature request.
Would love to see a typecasting method to allow for values like
4.5, 6, true, false, etc
Here is a method that I use for simple typecasting: