idiosyncinc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Dec-02 20:51 UTC
Equality Problems
Below is a snip of code that I''m having problems with the test in the .each method alway will return false and I don''t have a clue why. Could someone please help? @id=params[:id] @qty=params[:qty] print "ID=", @id print " QTY=", @qty,"\n" @cart.items.each{|x| print "ProdID=",x.product.id," QTY=",x.quantity," ",(x.quantity==(@qty)),"\n"} Here is the output of the code above ID=8 QTY=1 ProdID=8 QTY=1 false ProdID=5 QTY=1 false ProdID=7 QTY=1 false ProdID=8 QTY=2 false ProdID=8 QTY=3 false ProdID=7 QTY=2 false --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 2 Dec 2007, at 20:51, idiosyncinc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> > Below is a snip of code that I''m having problems with the test in > the .each method alway will return false and I don''t have a clue why. > Could someone please help? > > @id=params[:id] > @qty=params[:qty] > print "ID=", @id > print " QTY=", @qty,"\n" > @cart.items.each{|x| print "ProdID=",x.product.id," > QTY=",x.quantity," ",(x.quantity==(@qty)),"\n"}@qty is a string, x.quantity is an integer and so the 2 are never equal Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---