# Re: When are attr\_reader type methods called?

**URL:** <https://www.ruby-forum.com/t/re-when-are-attr-reader-type-methods-called/54202>\
**Category:** Ruby\
**Created:** [December 21, 2005, 5:50am UTC](https://www.ruby-forum.com/t/re-when-are-attr-reader-type-methods-called/54202 "2005-12-21T05:50:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dasch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dasch](https://www.ruby-forum.com/u/dasch)\
**Post date:** [December 21, 2005, 5:50am UTC](https://www.ruby-forum.com/t/re-when-are-attr-reader-type-methods-called/54202/1 "2005-12-21T05:50:15Z")

</div>

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  
#####################################################################################
