B
Ben Vishny
Hi all,
really stupid question. How can I evaluate the following code without
using a nested if.. then statement?
if parent.respond_to? "children"
if parent.children.size != 0
puts "Has children"
end
end
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?
Thanks,
Vish
really stupid question. How can I evaluate the following code without
using a nested if.. then statement?
if parent.respond_to? "children"
if parent.children.size != 0
puts "Has children"
end
end
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?
Thanks,
Vish