# Ruby and variable names

**URL:** <https://www.ruby-forum.com/t/ruby-and-variable-names/70969>\
**Category:** Ruby\
**Created:** [October 4, 2006, 12:16pm UTC](https://www.ruby-forum.com/t/ruby-and-variable-names/70969 "2006-10-04T12:16:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aidy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eada6e/32.png) [@aidy](https://www.ruby-forum.com/u/aidy)\
**Post date:** [October 4, 2006, 12:16pm UTC](https://www.ruby-forum.com/t/ruby-and-variable-names/70969/1 "2006-10-04T12:16:12Z")

</div>

Hi,

I have noticed Ruby coders using 1 character variables names (e.g. t,d)

Is this done because Ruby is a dynamic language and any object can be  
held in these variables?

aidy

---

<div class="post-metadata">

**Author:** ![aidy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eada6e/32.png) [@aidy](https://www.ruby-forum.com/u/aidy)\
**Post date:** [October 4, 2006, 12:32pm UTC](https://www.ruby-forum.com/t/ruby-and-variable-names/70969/2 "2006-10-04T12:32:13Z")

</div>

aidy wrote:

> Hi,
> 
> I have noticed Ruby coders using 1 character variables names (e.g. t,d)
> 
> Is this done because Ruby is a dynamic language and any object can be  
> held in these variables?
> 
> aidy

It’s done mostly because of laziness, usually when you’re just using the  
variable for one or two statements after it’s declared and then throwing  
it away again, such as in an iterator or rescuing an exception.

---

<div class="post-metadata">

**Author:** ![aidy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eada6e/32.png) [@aidy](https://www.ruby-forum.com/u/aidy)\
**Post date:** [October 4, 2006, 12:36pm UTC](https://www.ruby-forum.com/t/ruby-and-variable-names/70969/3 "2006-10-04T12:36:14Z")

</div>

> > I have noticed Ruby coders using 1 character variables names (e.g. t,d)
> > 
> > Is this done because Ruby is a dynamic language and any object can be  
> > held in these variables?

No. It’s more an idiomatic aspect of good programming style. It’s  
commonplace to use single-char variables for short-lived throwaway  
variables, such as loop counters, indexes and things like that, in  
pretty much every language I’ve ever used.

Martin

---

<div class="post-metadata">

**Author:** ![aidy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/eada6e/32.png) [@aidy](https://www.ruby-forum.com/u/aidy)\
**Post date:** [October 4, 2006, 1:56pm UTC](https://www.ruby-forum.com/t/ruby-and-variable-names/70969/4 "2006-10-04T13:56:23Z")

</div>

Also note that code posted to newsgroups and mailing-lists is usually  
not meant to be production quality; in that context many people use  
single-letter variable names for brevity, where in production they  
would follow the convention of writing self-documenting code.

Regards,  
Jordan
