Ben Vishny wrote: > Ideally I'd like to do: > > if parent.respond_to? "children" && parent.children.size != 0 > puts "Has Children" > end > > But I get an error if parent.children is undefined. Isn't there a way of > stopping if the first condition is false? Yes, but you're being bitten by the ambiguity of what you've written, which is resolved by precedence rules. I'm not sure exactly how your code was being parsed, but I guess something like if parent.respond_to?("children" && (parent.children.size != 0)) The rule is, if in doubt, add your own parentheses. The following all work as you expect: if (parent.respond_to? "children") && (parent.children.size != 0) puts "Has Children" end if parent.respond_to?("children") && parent.children.size != 0 puts "Has Children" end if parent.respond_to? "children" and parent.children.size != 0 puts "Has Children" end The last of these works because 'and' has very low precedence, but I'd say it's much better to be explicit with parentheses than clever with your knowledge of precedence rules. Incidentally, it's more idiomatic to use a symbol rather than a string for respond_to? if parent.respond_to?(:children) ... Regards, Brian. -- Posted via http://www.ruby-forum.com/.