Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Ruby Core and Standard Library Ruby Standard Library: Part 1 The Date Class

Jesse Fister
Jesse Fister
11,968 Points

Using the today method on the Date class, assign today's date to a variable called today.

Using the today method on the Date class, assign today's date to a variable called today.

my code is:

Date.today = today

I can't figure out what they want me to do. Thanks.

date.rb
date = Date.new
Date.today
Nick Stalter
Nick Stalter
9,616 Points

You may need to require the Date module in order to use Date.new/Date.today. Here is my example

require 'Date'
=> true
date = Date.new
#<Date: -4712-01-01 ((0j,0s,0n),+0s,2299161j)>
Date.today
#<Date: 2015-11-23 ((2457350j,0s,0n),+0s,2299161j)>

Is this the kind of output you are looking for?

edited for formatting

2 Answers

William Li
PLUS
William Li
Courses Plus Student 26,867 Points

Hi Jesse.

Your use of the today method on Date class is correct, however, like part 1 of the challenge, you need to assign that value to a variable as well.

date = Date.new
today = Date.today

Hope it makes sense.

Sean Flanagan
Sean Flanagan
33,234 Points

Hi William.

Thanks for your suggestion; it worked for me.

Sean