From: Simen Date: 2006-05-03T01:53:18+09:00 Subject: Re: Mixin Syntax for Newbies Nathan Olberding wrote: > I'm trying to start using mixins and I'm having a little syntactual > trouble, if that's a word. > > Here's my test code: > > --------------- > module One > @one = "One!" > attr_reader :one > end > > class Two > include One > def initialize > puts @one > end > end > > this = Two.new > ---------------- > > I have tried several variations on this, but Two.one always seems to > come out as "nil". Is it possible to set it to "One!" by default? In the above code, @one is actually an instance variable of module One: One.instance_variable_get "@one" # => "One!" -- Posted via http://www.ruby-forum.com/.