Forum: Ruby Re: When are attr_reader type methods called?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Daniel S. (Guest)
on 2005-12-21 06:50
(Received via mailing list)
class A
  call_this ("hello world")
  def call_this(arg)
    p arg
  end
end

gives me

NoMethodError: undefined method `call_this' for A:Class
        from (irb):3

So you're obviously doing something more than just what you posted -
what's in the ...?

class A
   attr_reader :monkeys
end

is roughly equivalent to writing:

A = Class.new
A.define_method :monkeys {
	instance_variable_get(:@monkeys)
}

Is that what you're asking? Try posting a short piece of code with
actual and expected outputs.

#####################################################################################
This email has been scanned by MailMarshal, an email content filter.
#####################################################################################
#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared
by NetIQ MailMarshal
#####################################################################################
This topic is locked and can not be replied to.