val = BigDecimal.new("0")
Running this statement shows uninitialized constant bigdecimal (nameerror) error.
Then modifying to:
require "bigdecimal"
val = BigDecimal.new("0")
That's ok.
BigDecimal belongs to Ruby Standard Library. So I need to require 'bigdecimal'?
Question:
BigDecimal defined? Just because it's in the Ruby core doesn't mean it's automatically imported into your program. If it loaded everything it'd take forever to get Ruby started.
The correct way to do this is to use require. Why? It's only loaded if you need it.
The reason you can't find bigdecimal.rb is because it's written in C for performance reasons, so it's a library that's actually imported on-demand.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With