# Method names-how to indicate get vs set type of method?

**URL:** <https://www.ruby-forum.com/t/method-names-how-to-indicate-get-vs-set-type-of-method/152657>\
**Category:** Ruby\
**Created:** [November 6, 2008, 4:09am UTC](https://www.ruby-forum.com/t/method-names-how-to-indicate-get-vs-set-type-of-method/152657 "2008-11-06T04:09:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [November 6, 2008, 4:09am UTC](https://www.ruby-forum.com/t/method-names-how-to-indicate-get-vs-set-type-of-method/152657/1 "2008-11-06T04:09:32Z")

</div>

hi,

What is the naming convention for method names to clarify whether its  
a get or set type of method?

tks

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [November 6, 2008, 4:21am UTC](https://www.ruby-forum.com/t/method-names-how-to-indicate-get-vs-set-type-of-method/152657/2 "2008-11-06T04:21:49Z")

</div>

On Nov 5, 9:07 pm, “Greg H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> What is the naming convention for method names to clarify whether its  
> a get or set type of method?

Ruby methods can end in =, so that’s a good choice.

class Square  
def height  
@height  
end

```
def height=(val)
  @height = val
end

```

end

Note that you can do the same in a much easier way.

class Square  
attr\_accessor :height  
end
