[ruby-core:63950] [ruby-trunk - Feature #10083] [Rejected] String.to_i unexpected behavior

From: nobu@...
Date: 2014-07-23 05:38:34 UTC
List: ruby-core #63950
Issue #10083 has been updated by Nobuyoshi Nakada.

Description updated
Status changed from Open to Rejected

You can use `Integer("String")` instead.

----------------------------------------
Feature #10083: String.to_i unexpected behavior
https://bugs.ruby-lang.org/issues/10083#change-47972

* Author: joseph castro
* Status: Rejected
* Priority: Normal
* Assignee: ruby-core
* Category: misc
* Target version: current: 2.2.0
----------------------------------------
Hi

There's the issue:

~~~ruby
"String".to_i  => 0  
~~~

This must be NIL or at least error, but no 0, because the string is not a number, also:

~~~ruby
"10String".to_i => 10 
~~~

Is not 10, because "10String" is not a number, maybe is necessary a new method to get a number from any string, because to_i is to convert into a Integer and that should return an error.

Greetings everyone



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

In This Thread

Prev Next