On Tue, Oct 12, 2010 at 1:50 PM, Leonel *.* <leonelsantos.me / gmail.com> wrote: > @Josh: I'm sorry I thought since all I need to create is a Ruby if > statement it would fall under the Ruby forum. It's true I'm using it in > a Rails context but it basically is just a Ruby question. But if you > still want me to move it I will. > > @Alex: could you please help me in the Ruby on Rails forum? > No, this is clearly a Ruby question, albeit in the context of Rails. Some folks here are just a llttle too eager to pull there "this is the Ruby not the Rails" forum trigger. a = [] defined? a # => "local-variable" defined? a.last # => "method" defined? a.last.foo # => nil a.last.nil? # => true defined? a.last.nil? # => "method" So if defined?(appointment.client.email) returns "method" if appointment refers to an object with a client method which returns an object with an email method. It doesn't send that last message. Normally in Ruby if you would simply check that the email value was non-nil and idiomatically this would just be if appointment.client.email #.... end Because nil and false are the only non-truthy values in Ruby and it would be unusual to set the email to false. -- Rick DeNatale Help fund my talk at Ruby Conf 2010:http://pledgie.com/campaigns/13677 Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale