Ruby's Reserved Words - dummies

By Christopher Haupt

Part of Ruby For Kids For Dummies Cheat Sheet

Ruby has a small set of words that are considered “reserved” and shouldn’t be used when naming variables or methods. The following table contains a list of Ruby reserved words that should not be used.

alias and BEGIN
begin break case
class def defined?
do else elsif
END end ensure
false for if
module next nil
not or redo
rescue retry return
self super then
true undef unles
until when while
yield _ _FILE_ _ _ _LINE_ _

In addition, you should check the standard Ruby documentation when naming your own classes and modules. If you use a name that is identical to an existing class (for example, String), you won’t create a new class, but rather change the existing one! This can have unexpected effects if you aren’t doing it on purpose.