Project

General

Profile

Bug #17032

Updated by sawa (Tsuyoshi Sawada) over 3 years ago


 As a Ruby user I would expect `to_f` `.to_f` and `to_d` `.to_d` to behave identically. Specifically, 

 Specifically `nil.to_d` should behave like `nil.to_f`. 

 ```ruby 
 `nil.to_f` 


 2.5.5 :001 > require 'bigdecimal' 
  => true 
 2.5.5 :002 > require 'bigdecimal/util' 
  => true 
 2.5.5 :003 > nil.to_f # 
  => 0.0 
 2.5.5 :004 > nil.to_d # >> 
 Traceback (most recent call last): 
         2: from /Users/tsloboda/.rvm/rubies/ruby-2.5.5/bin/irb:11:in `<main>' 
         1: from (irb):4 
 NoMethodError (undefined method `to_d' for nil:NilClass) 
 ``` 

 Users # users should not have to resort to this: 

 ```ruby 
 2.5.5 :005 > nil.to_f.to_d #    
  => 0.0 
 ``` 

Back