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


#1

Hi everyone,

I'm stuck on that exercice and didn't find any usefull answers yet in this forum so please, help me to figure this out (here is my code):

require 'date'
    module Date
    def Date
    puts Date.today
    end
end

I read somewhere that the Date module has to be imported / required that way:

But I don't get it, what's wrong once I have required the missing Date module ?
Thank you for the help guys !

Nicolas


#2

https://www.codecademy.com/en/courses/ruby-beginner-en-zfe3o/1/4

We are given the statement,

puts Date.today

and asked to import the date module that will enable the line.

require 'date'

None of the other lines of code are asked for or needed.


#3

Thank you @mtf, I was convinced that the module Date has to be specified (at least a bit) but it was way easier in reality. Are all the others imported modules such as Date that easy to use? I mean only require 'module' then ask this module to do something ? If yes it's pretty cool ! :slight_smile:


#4

Relative ease, perhaps, especially when it comes to not reinventing the wheel. As learners, though, we will want to do things the nuts and bolts way until we are fully comfortable with the built in components and the basic constructs. The beginning is never a good time to start learning shortcuts, else many of the bricks and mortar approaches are never learned or practiced. At least that's my opinion.


#5

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