There are many web pages that list the reserved keywords in Ruby, but what if you want to make absolutely sure the “other guy’s” list is correct? Some webpages don’t specify which version of Ruby they are referencing and the keyword list does change (although granted, not that often). For example, the __ENCODING__ keyword was added in Ruby 1.9.1. If you want to be absolutely sure about the reserved words list in Ruby, the best way is to go straight to the source code:
All of the Ruby source code is available on the Ruby GitHub page. Inside the defs folder you’ll find a keywords file. Open it up an enjoy the goodness.
Note: For Ruby 1.8.7 and earlier there is no defs folder. The keywords file lived in the root directory.
The following list will jump you straight to the keywords file for various versions of Ruby.
You can download the source code directory from the Ruby Lang website and navigate to the same directories as above.
Ruby 2.1.0 Reserved Words List
Here is a quick reference for the 41 keywords used in Ruby 2.1.0:
We hope you found this article useful. If you see any mistakes, missing features or ways to improve it, please let us know in the comments below so we can update its contents. If you're willing to link to us, we would sincerely appreciate it!