10. A Few Requirements - Why `date` rather than `Date`?


#1

10.A Few Requirements

Why should I require date rather than Date? since we are calling Date.today rather than date.today

require 'date'
puts Date.today

Another question, why method today is called using a single point . rather than :: like Math::PI since Date is a module rather than a class?


#2

Date is a class that is defined in date.rb
When you require the file, you get the stuff defined in there.
Date is not a module.

. can only be used to call methods
:: looks for constants first, and then for methods


Exercise 10: How to import the missing 'date' module ? Please help :-)
#3

If 'date' is a class, the instructions seem to have an error: calling it the "Ruby Date Module"

"We want to use the Ruby Date module to show today's date, but we haven't required it yet!"


#4

That's wrong in two ways, yes.
The Date class isn't inside a module and require is used to pull in files, not modules (though those exist in files)

It's common that people get this kind of stuff wrong all the time and often only try to say things approximately right. Usually if you know exactly what happens then you'll get most of the terminology right as well. It's important to only trust select sources on the finer details of terminology, codecademy certainly isn't such a source.

To further add to the confusion plenty of languages use similar concepts and similar terms but not always mapping between those the same way or being subtly different.


#5

"It's important to only trust select sources on the finer details of terminology, codecademy certainly isn't such a source."

So whereabouts would you recommend we look to get the 'finer' details of the terminology? It seems to me that proper terminology is a very important part to learning any language.


#6

By method rather than location - keeping guesses and certainties separate and looking it up when you need to be certain or there's a contradiction. Assume that you're going to get some things wrong and be ready to make replacements when you find better understanding. Sometimes you get confirmation from a source you trust, or find a way to reason about something so that you can accept it as certain.


#7

This helped me look at my question differently, thank you.