Project

General

Profile

Actions

Bug #9574

closed

Inconsistent behavior between Kernel#Float and to_f

Added by robin850 (Robin Dupret) over 10 years ago. Updated over 5 years ago.

Status:
Closed
Assignee:
Target version:
-
ruby -v:
2.1.0
Backport:
[ruby-core:61124]

Description

Hello,

Sorry if this has still been requested, I haven't found anything about this on the tracker. There is an inconsistent behavior between #to_f and Float() with strings. I don't know whether this is intended or not but if it is, there is at least something wrong in Kernel#Float's documentation:

Numeric types are converted directly, the rest are converted using arg.to_f.
>> "123.".to_f
=> 123.0
>> Float("123.")
ArgumentError: invalid value for Float(): "123."
from (pry):1:in `Float'

The issue has been originally reported here https://github.com/rails/rails/issues/11800.

Have a nice day.


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #11736: Float(arg) not consistent with documentationClosedhsbt (Hiroshi SHIBATA)Actions

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

  • Category changed from core to doc

Updated by zzak (zzak _) over 10 years ago

  • Status changed from Open to Assigned
  • Assignee set to zzak (zzak _)

Thanks for the report!

Actions #3

Updated by jeremyevans0 (Jeremy Evans) over 5 years ago

  • Related to Bug #11736: Float(arg) not consistent with documentation added
Actions #4

Updated by jeremyevans0 (Jeremy Evans) over 5 years ago

  • Status changed from Assigned to Closed
  • Backport deleted (1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN)
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0