[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: 1978 != 1978

Richard

12/19/2008 10:36:00 PM

My guess is that the way computer represents number is not exactly whole number but I m sure others can better correct this issue
------Original Message------
From: Shandy Nantz
Sender: shandybleu@yahoo.com
To: ruby-talk ML
ReplyTo: ruby-talk@ruby-lang.org
Subject: 1978 != 1978
Sent: Dec 19, 2008 5:27 PM

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 %>

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,

-S
--
Posted via http://www.ruby-....



Sent from my Verizon Wireless BlackBerry