Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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,868 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,235 Points

Hi William.

Thanks for your suggestion; it worked for me.

Sean