Forum: Ruby on Rails Using ParseDate in for loop

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
98d1d8abae0d61c064234a4ac46c2fc0?d=identicon&s=25 Jason Gilstrap (Guest)
on 2006-05-22 01:37
(Received via mailing list)
Hi,

I'm trying to use ParseDate within a for loop but I get this error:

can't dup NilClass


Any suggestions for making this work?

Thanks,
-Jason
C9c7a65848f13e2b1a226bbe43bc3672?d=identicon&s=25 Pete Yandell (pete)
on 2006-05-22 03:02
(Received via mailing list)
Jason,

That's not nearly enough info for anyone to help with your problem.
Parsedate, of course, works just the same whether it's in a for loop
or not. Try posting some actual code.

Cheers,

Pete Yandell
http://9cays.com/
98d1d8abae0d61c064234a4ac46c2fc0?d=identicon&s=25 Jason Gilstrap (Guest)
on 2006-05-22 05:07
(Received via mailing list)
for res in @response
    date1 = Date.today
    date2 = ParseDate.parsedate(date_from_string)

    if  (date1 - date2 <= 365)
        count1 += 1
    end
end
C9c7a65848f13e2b1a226bbe43bc3672?d=identicon&s=25 Pete Yandell (pete)
on 2006-05-23 01:39
(Received via mailing list)
The thing that's likely to be causing your error is that
date_from_string is nil.

(There are also several other problems with your code, but I'll let
you cross those bridges as you come to them.)

Pete Yandell
http://9cays.com/
This topic is locked and can not be replied to.