Take the 2-minute tour ×

Most Ruby constants follow the C convention of having all caps.

But is it considered legitimate style to name Ruby constants using CamelCase? I just think it is easier to type that way, since my Caps Lock is remapped to CTRL.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

According to the ruby specification, modules are constants. There is a philosophy behind it, and there is no reason they should be written differently. If modules are written in camel case, why not for the rest of the constants? Although writing in upper case seems to be the majority, I do write them all in camel case. In addition, writing in upcase reminds me of the classic languages like Basic, Fortran, etc., and does not look sophisticated.

ecologic points out compatibility with IDE, but if that causes a problem, then it's the IDE's bug. An IDE should follow the language's specification as strictly as possible, not the convention that people follow.

share|improve this answer
"writing in upcase reminds me of the classic languages like Basic, Fortran, etc." - LOLCODE CAN HAZ ALL CAPS!!1! –  Andrew Grimm Jun 27 '11 at 23:10
For the benefit of those new to Ruby, classes are subclasses of modules, and they also use CamelCase. –  Andrew Grimm Jun 27 '11 at 23:11

Well, you should ask to the people in your team and get a common decision, as you don't want two conventions in the same project.

In my opinion it's always a good idea to follow the proper convention of each language. I follow conventions that I don't really like. Also some IDE could interpretate the constant differently.

share|improve this answer
General readability gets worse for someone external, then if you decide to contribute to any opensource project, you will have to strive to go back to the regular convention. –  ecoologic Jun 27 '11 at 17:20

Your Answer


