Why can not set value to instance variable of Class?
@classname = name
@paralist = Hash.new
$cellparalist = ParaList.new("AAA")
a = Hash.new
a = paraclass.paralist
#Error:in `addpara': undefined method `paralist' for #<ParaList:0xc6eff5
b = Hash.new
a = b
Posted via http://www.ruby-forum.com/.
Re: Why can not set value to instance variable of Class?
[Note: parts of this message were removed to make it a legal post.]
You've defined an attr_writer for :paralist, but need an attr_reader for it
in order for the method you are calling to be defined. You probably want to
change attr_writer to attr_reader, or use attr_accessor if you really want
it to still be writable. attr_writer defines a separate method called
paralist=. You can call that method using paraclass.paralist = foobar.
On Wed, Sep 22, 2010 at 9:23 PM, iMelody Ooo <firstname.lastname@example.org> wrote:
> class ParaList
> def initialize(name)
> @classname = name
> @paralist = Hash.new
> $cellparalist = ParaList.new("AAA")
> def MmlParse.addpara(paraclass,mo,mmlparalist)
> a = Hash.new
> a = paraclass.paralist
> #Error:in `addpara': undefined method `paralist' for #<ParaList:0xc6eff5
> b = Hash.new
> a = b
> Posted via http://www.ruby-forum.com/.
Medioh! A Kudelski Brand
|All times are GMT. The time now is 10:23 PM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.