From: "Florian Groß" Date: 2006-06-05T20:36:32+09:00 Subject: Re: isset kinda function Alex Copot wrote: > Well, I have something like this > > if session[:cart][product_id] > 1 > session[:cart][product_id] = session[:cart][product_id] + 1 > else > session[:cart][product_id] = 1 > end > > But it doesn't work. I get this. > > You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occured while evaluating nil.[] Seems like session[:cart] is nil. You can just do if session[:cart] then ... end And things will work correctly. What you proably want is to initialize session[:cart] to an object, though. You can do that like: session[:cart] ||= default Hope this helps. -- http://flgr.0x42.net/