From: Jeff McNeil Date: 2006-02-27T05:57:24+09:00 Subject: Re: Using attr_writer? Are you running it in irb? As someone else mentioned.. you'll get a "nil" message as that's the return value of puts. -Jeff On Feb 26, 2006, at 3:48 PM, Huw Collingbourne wrote: > Curious. I just copied, pasted and ran your code. It produces the > string > 'baz'. I don't get an error. > > best wishes > Huw Collingbourne > ================================ > Bitwise Magazine > www.bitwisemag.com > Dark Neon Ltd. > ================================ > > > "Joe" wrote in message > news:2df9ba1d3b2002133798b2b6d3d429fc@ruby-forum.com... >> I'm confused about attr_writer. I thought it worked like this: >> >> class Foo >> attr_writer :bar >> >> def do_stuff >> puts @bar >> end >> end >> >> foo = Foo.new >> foo.bar = 'baz' >> foo.do_stuff # gives nil error >> >> Can somebody enlighten me? :) >> >> Thanks, >> Joe >> >> -- >> Posted via http://www.ruby-forum.com/. >> >> > > >