Skip to content

.to_d acts differently in jRuby 9.0.x than Ruby 2.2.x #3504

@ootoovak

Description

@ootoovak

How to replicate

Open up IRB in jRuby 9.0.4.0:

require "bigdecimal"; nil.to_s.to_d
=> #<BigDecimal:4d6025c5,'0.0',1(4)>

Opening up IRB in Ruby 2.2.3:

require "bigdecimal"; nil.to_s.to_d
NoMethodError: undefined method `to_d' for "":String
    from (irb):1
    from /Users/ootoovak/.rubies/ruby-2.2.3/bin/irb:11:in `<main>'

System

OS X 10.11.1
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
  • To be clear I prefer jRuby's behaviour in this case but just wanted to point out the difference. In fact I would prefer to be able to do nil.to_d given a choice.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions