I'm working with a large codebase where I see the following code a lot:
if foo.respond_to?(:bar)
unless foo.bar.nil?
# do stuff
end
end
Is there a way to do that in one line?
[Final Answer]
if foo.respond_to?(:bar) and not foo.bar.nil?
# do stuff
end