From: "David A. Black" Date: 2008-12-20T07:40:15+09:00 Subject: Re: 1978 != 1978 Hi -- On Sat, 20 Dec 2008, Shandy Nantz wrote: > I have these years that I am trying to compare to see if they are equal > and when my code get to the right year in question where it is supposed > to equate to true, it doesn't. Here is my code: > > <% 1900.upto(year) do |i| %> > <%= option_tag(i, i, @user.dobyear.to_s == i.to_s ? true : false) %> > <% end %> An aside: == returns true or false, so you don't have to do the whole ? true : false thing. > When I do some 'puts' I get a condition where '1978' == '1978' and that > results in a false value and I can't figure out why. Why in Ruby does > this happen? Thansk, Are there spaces around @user.dobyear? I'm not sure what you mean about puts, except that puts returns nil, but I'm not sure how that fits in with your question. David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2)