# Attr\_accessor and reader and writer convert it to normal Methods style!

**URL:** <https://www.ruby-forum.com/t/attr-accessor-and-reader-and-writer-convert-it-to-normal-methods-style/221710>\
**Category:** Ruby\
**Created:** [July 27, 2012, 3:09am UTC](https://www.ruby-forum.com/t/attr-accessor-and-reader-and-writer-convert-it-to-normal-methods-style/221710 "2012-07-27T03:09:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [July 27, 2012, 3:09am UTC](https://www.ruby-forum.com/t/attr-accessor-and-reader-and-writer-convert-it-to-normal-methods-style/221710/1 "2012-07-27T03:09:20Z")

</div>

Hello,

How can i express the attributes methods using normal method styles (the  
long coding way) to define them?

attr\_accessor :name  
attr\_writer :name  
attr\_reader :legs, :arms

My own try is below. If I’m wrong, then correct it for me by re-typing  
it.

My answer is:

def name=(name)  
@name = name  
end  
def name=(legs,arms)  
@name = legs, arms  
end

def name  
@name  
end

Thank you!

---

<div class="post-metadata">

**Author:** ![rubina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e47c2d/32.png) [@rubina](https://www.ruby-forum.com/u/rubina)\
**Post date:** [July 27, 2012, 3:34am UTC](https://www.ruby-forum.com/t/attr-accessor-and-reader-and-writer-convert-it-to-normal-methods-style/221710/2 "2012-07-27T03:34:04Z")

</div>

On 27/07/2012, at 1:09 PM, Ruby S. wrote:

> How can i express the attributes methods using normal method styles (the  
> long coding way) to define them?
> 
> attr\_accessor :name  
> attr\_writer :name  
> attr\_reader :legs, :arms

These are the equivalent of…

# attr\_accessor :name

def name= value  
@name = value  
end

def name  
@name  
end

# attr\_writer :name

def name= value  
@name = value  
end

# attr\_reader :legs, :arms

def legs  
@legs  
end

def arms  
@arms  
end

Henry

---

<div class="post-metadata">

**Author:** ![rubina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e47c2d/32.png) [@rubina](https://www.ruby-forum.com/u/rubina)\
**Post date:** [July 27, 2012, 3:52am UTC](https://www.ruby-forum.com/t/attr-accessor-and-reader-and-writer-convert-it-to-normal-methods-style/221710/3 "2012-07-27T03:52:12Z")

</div>

Henry M. wrote in post #1070351:

> On 27/07/2012, at 1:09 PM, Ruby S. wrote:  
> Thank you for the great answer 🙂
