Is there a .?
operator in Ruby that checks if an object is nil
before calling a method on it?
For instance if I have to code:
if person and person.neighbor and person.neighbor.house and person.neighbor.house.rooms
person.neighbor.house.rooms.each do |room|
blah
end
end
Is there a better way than having to do an if check on everything?
And please don't say "code in such a way that these objects cannot ever be nil
", I am getting these things from an API call and can't control it.