diff options
author | Koichi ITO <koic.ito@gmail.com> | 2017-01-15 11:44:00 +0900 |
---|---|---|
committer | Koichi ITO <koic.ito@gmail.com> | 2017-01-15 12:01:55 +0900 |
commit | 7b3d663b4d9e58c8bc6c13e2b0ef703af2063a21 (patch) | |
tree | 428061f22352efbb589103b82d1b33b8217556bd | |
parent | aaece61a53dc943ac0e4b696c39ba61f46b7c7a3 (diff) | |
download | rails-7b3d663b4d9e58c8bc6c13e2b0ef703af2063a21.tar.gz rails-7b3d663b4d9e58c8bc6c13e2b0ef703af2063a21.tar.bz2 rails-7b3d663b4d9e58c8bc6c13e2b0ef703af2063a21.zip |
Several representation of BigDecimal has changed in Ruby 2.4.0+ [ci skip]
cf. https://github.com/ruby/bigdecimal/pull/42
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/duplicable.rb | 7 | ||||
-rw-r--r-- | guides/source/active_support_core_extensions.md | 10 |
2 files changed, 16 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/duplicable.rb b/activesupport/lib/active_support/core_ext/object/duplicable.rb index ea81df2bd8..ed0df42b0a 100644 --- a/activesupport/lib/active_support/core_ext/object/duplicable.rb +++ b/activesupport/lib/active_support/core_ext/object/duplicable.rb @@ -107,6 +107,13 @@ class BigDecimal # BigDecimals are duplicable: # # BigDecimal.new("1.2").duplicable? # => true + # + # In Ruby 2.4.0: + # + # BigDecimal.new("1.2").dup # => 0.12e1 + # + # Whereas in Ruby 2.2 and 2.3: + # # BigDecimal.new("1.2").dup # => #<BigDecimal:...,'0.12E1',18(18)> def duplicable? true diff --git a/guides/source/active_support_core_extensions.md b/guides/source/active_support_core_extensions.md index 67bed4c8da..b9f096b82a 100644 --- a/guides/source/active_support_core_extensions.md +++ b/guides/source/active_support_core_extensions.md @@ -1980,7 +1980,15 @@ and that symbol specifiers are also supported: BigDecimal.new(5.00, 6).to_s(:db) # => "5.0" ``` -Engineering notation is still supported: +Engineering notation is still supported. + +In Ruby 2.4: + +```ruby +BigDecimal.new(5.00, 6).to_s("e") # => "0.5e1" +``` + +Whereas in Ruby 2.2 and 2.3: ```ruby BigDecimal.new(5.00, 6).to_s("e") # => "0.5E1" |