From: Brian Candler Date: 2010-03-31T19:23:17+09:00 Subject: Re: why getting error for this code fragment Rob Biedenharn wrote: > Try it like this: > > 5 class Movie_Info > 6 attr_accessor :runtime, :language, :sound, :color > 7 def to_str > 38 puts (runtime==nil ? 'nil' : runtime)+'&&&'+ > (language==nil ? 'nil' : language)+'&&&'+(color==nil ? 'nil' : color) > +'&&&'+(sound==nil ? 'nil' : sound) > 39 return str > 40 end > 41 end Or even: def to_str "#{runtime||'nil'}&&&#{language||'nil'}&&&#{color||'nil'}&&&#{sound||'nil'}" end -- Posted via http://www.ruby-forum.com/.