Issue #12732 has been updated by nobu (Nobuyoshi Nakada).


Since `Integer()` has `radix` optional argument, new optional argument might be confusing.
A keyword argument or a block would be better, I think.

----------------------------------------
Feature #12732: An option to pass to `Integer`, `Float`, to return `nil` instead of raise an exception
https://bugs.ruby-lang.org/issues/12732#change-70274

* Author: tenderlovemaking (Aaron Patterson)
* Status: Feedback
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
I would like to be able to pass an option to `Integer()` and `Float()` so that they don't raise an exception, but return `nil` instead.  For example:

~~~
Integer(string, exception: false)
~~~

The reason I want this function is so that I can convert strings from YAML or JSON to integers if they parse correctly, or just return strings if they can't be parsed.

---Files--------------------------------
integer-parse.pdf (29 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>