From: matz@... Date: 2017-03-13T09:06:43+00:00 Subject: [ruby-core:80123] [Ruby trunk Bug#13105] `String#to_f` and `String#to_r` don't stop at successive underscores Issue #13105 has been updated by Yukihiro Matsumoto. Assignee changed from Yukihiro Matsumoto to Nobuyoshi Nakada We should have more consistency here. `to_i` and `to_r` should be more restrictive on treating `_`. Namely, * `_` should be within digits * only one `_` allowed between digits Matz. ---------------------------------------- Bug #13105: `String#to_f` and `String#to_r` don't stop at successive underscores https://bugs.ruby-lang.org/issues/13105#change-63549 * Author: Nobuyoshi Nakada * Status: Assigned * Priority: Normal * Assignee: Nobuyoshi Nakada * Target version: 2.5 * ruby -v: r57270 * Backport: 2.2: REQUIRED, 2.3: REQUIRED, 2.4: REQUIRED ---------------------------------------- `Integer()`, `Float()` and `Rational()` errs at successive underscores, and `String#to_i` stops the conversion there. But `String#to_f` and `String#to_r` continue the conversion like as there were just one underscore. Is this intentional? ```ruby "1_2".to_i #=> 12 "1__2".to_i #=> 1 "1.__2".to_f #=> 1.2 "0.1__2".to_r #=> (3/25) == 0.12 ``` -- https://bugs.ruby-lang.org/ Unsubscribe: