From: Christoph Date: 2002-09-10T09:13:10+09:00 Subject: Re: scopes "Kontra, Gergely" wrote in .... > >The instance variables are always private in Ruby: > >you can't access the instance variables of an object from > >a different object. > > What if I write mail and pass instead of @mail and @pass > Gergo This does not work either - you have to ``transport'' @mail as an argument into the @pass scope. However, a local ``mail'' could be seen been in a ``@pass'' singleton method defined via ``define_method''. --- class Foo def initialize @pass = Object.new end def mail=(got) mail = got class << @pass ;self end.send(:define_method,:check) \ { || (mail =~ /milk/) ? "yes" : "no" } got end def got_milk? p @pass.check end end a,b = Foo.new, Foo.new a.mail = "books" b.mail = "milk and cookies" a.got_milk? # no b.got_milk? # yes --- /Christoph