From: "F. Senault" Date: 2008-08-02T06:30:11+09:00 Subject: Re: Help finding this syntax error Le 1 ao�t 2008 � 22:53, Patrick Li a �crit : > Hmm that makes more sense. > But now i'm confused why my code worked after removing the outside > parenthesis. > > when i type this: > if FieldTypes.key? field && FieldTypes[field].respond_to? :select > > shouldn't ruby be seeing this? > if (FieldTypes.key? field && FieldTypes[field].respond_to?) :select Nope. It sees : if FieldTypes.key?(field && FieldTypes[field].respond_to?(:select)) Example : >> h = { 'aaa' => 1 } => {"aaa"=>1} >> if h.has_key? 'aaa' && h.length > 0 then "ok" else "nok" end => "nok" But... >> h[true]=1 => 1 >> if h.has_key? 'aaa' && h.length > 0 then "ok" else "nok" end => "ok" I always parenthesise the arguments unless the test is very simple (i.e. "if hash.has_key? :toto" is ok, but nothing more). Fred -- We'll find the perfect place to go where we can run and hide I'll build a wall and we can keep them on the other side... But they keep waiting And picking... It's something I have to do I was there, too Before everything else I was like you (Nine Inch Nails, The Fragile)