I recently was doing an exercism.io exercise to determine a person's gigagsecond anniversary, given her/his birthday. If you want, you can nitpick me here.
While doing this exercise, I discovered in irb that I get different results if I did not require 'date'
.
vs using require 'date'
.
Further I tried the same in repl.it, and get an error if I try to use Date
without require 'Date'
.
I was able to find some responses to the 'uninitialized constant' error (Why is Ruby's Date class automatically loaded but DateTime is not? and Why does Date exist in Ruby before it is required?.) which led me down the path of perhaps versioning is the culprit; but, I couldn't find any overwhelmingly definitive response.
I am using: Ruby 2.1.3, irb 0.9.6 (which I believe uses Ruby 2.0.0) and repl.it is using Ruby 1.8.7(beta).
So, is this a version thing? ...an irb vs Ruby thing? ...a Date class in the standard library + Date module thing? Or simply that I'm just a n00b?
Lastly I messed around a bit more with the date objects in irb and got an error 'Maybe IRB bug!'
(FWIW, I did the same thing for 'time' in irb but this time, got the same result regardless if I required 'time'.)