Exercise 10



I'm not exactly stuck but have a question. When requiring the given module, we use 'date' but the module name is 'Date' yet works nonetheless. When I tried capitalizing the 'D' in the require statement, it does not work. Is this method a case-sensitive method where all characters must be lower case?

Replace this line with your code.


Good question!

In most cases, when we do require 'module' in Ruby what we're telling Ruby to is to to allow us to use what's contained in the file with that name.

So, in the case of require 'date', we're asking Ruby to find a file called date (most likely with a file extension of .rb), and then give us access to what's in that file. By convention classes in Ruby, like Date will be contained in a file with the same name, except it will be lowercase. So, basically, the Date class comes from the date file.

Hopefully that makes sense!


:bow: thats good

can such a file include more than one module??


Yeah. It doesn't happen too often in the core Ruby language itself, but It's quite a common way of organizing code in Ruby projects (especially larger codebases). You'll see a lot of examples of this as you begin to look at other people's code in the future.


so till now i can say that i can use the scope resolution operation to choose from two constants -with the same name- in diferent modules in the same file ??


That's correct! That's a good example of how namespacing and the scope resolution operator works in Ruby


This was a very helpful response! Thank you! :>


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.