Project

General

Profile

Actions

Bug #13105

closed

`String#to_f` and `String#to_r` don't stop at successive underscores

Added by nobu (Nobuyoshi Nakada) almost 5 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Normal
Target version:
[ruby-core:78977]

Description

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?

"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
Actions

Also available in: Atom PDF