# Style question: when to use underscores

**URL:** <https://rubytalk.org/t/style-question-when-to-use-underscores/19924>\
**Category:** ruby-talk\
**Created:** [3 August 2005 13:52 UTC](https://rubytalk.org/t/style-question-when-to-use-underscores/19924 "2005-08-03T13:52:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Vallner](https://avatars.discourse-cdn.com/v4/letter/d/eb9ed0/32.png) [@David\_Vallner](https://rubytalk.org/u/David_Vallner)\
**Post date:** [3 August 2005 13:52 UTC](https://rubytalk.org/t/style-question-when-to-use-underscores/19924/1 "2005-08-03T13:52:33Z")

</div>

Citát "francisrammeloo@hotmail.com" \<francisrammeloo@hotmail.com\>:

> But the Ruby built in classes  
> do not always use them.  
> For example: IO#readlines  
> Why not: IO#read\_lines ?

I find that to be very rare in the standard libs, and almost exclusively when  
the library in question is a relatively thin C binding. In that specific case,  
I prefer to iterate over the lines of a file to avoid loading the whole thing  
into memory. It's a habit you get into the first time you do a script working  
with 200MB log files 😉

For the love of god, resist the urge to use PascalCase or CamelCase for method  
names, or more insane conventions like the one with defining and calling  
methods reflexively (abandon all hope of an eventual Rite optimizing that).  
Almost the whole core API and all of the standard lib I've used so far uses  
underscores everywhere, both of the style guides recommend doing that, and  
that's reason enough to do so. A convention should always take preference over  
personal taste.

Side note: minor snags go to the Python standard lib for using every possible  
convention, not so minor fluffs go to the wxRuby people for ruby-izing the  
method names, although I'd welcome the get\_foo and set\_foo methods to be made  
into proper accessors while it's still morally acceptable to cause that much  
breakage.

David

---

<div class="post-metadata">

**Author:** ![Florian\_Frank2](https://avatars.discourse-cdn.com/v4/letter/f/a587f6/32.png) [@Florian\_Frank2](https://rubytalk.org/u/Florian_Frank2)\
**Post date:** [3 August 2005 16:13 UTC](https://rubytalk.org/t/style-question-when-to-use-underscores/19924/2 "2005-08-03T16:13:28Z")

</div>

It was a joke, not a serious advice. Come on, laugh, it's funny. Hahaha...

> **···**
>
> On 2005-08-03 22:52:33 +0900, david@vallner.net wrote:
> 
> > For the love of god, resist the urge to use PascalCase or CamelCase for method  
> > names, or more insane conventions like the one with defining and calling  
> > methods reflexively (abandon all hope of an eventual Rite optimizing that).
> 
> --  
> Florian Frank
