1. Ruby

Reserved Words in Ruby Programming Language

Reserved Words in any programming language are keywords whose meaning have been defined internally in the language itself. These words are not allowed to be used by Programmers as variable names or function names. If in case you do use these as variable/function names then during execution some error will be thrown.

Below is a table listing all of Reserved Words in Ruby Programming Language with description for each one.

Reserved WordDescription
BEGINCode enclosed in { } to run before program runs
ENDCode enclosed in { } to run when program ends
aliasCreate alias for existing method, operator, global variable
andLogical AND Operator
beginBegins a block of code
breakTerminate a loop
caseComparing an expression with matching when clause which closes with end
classDefining a class
def Defining a function/method
defined?To check if some variable, function exists or not
doBegins a code block and execute code in the block, this ends with end keyword
elseExecutes following code if previous conditional is not true
elsifExecutes following code if previous conditional is not true
endFor ending a code block which started with keywords like begin, class, def, do, if
ensureAlways execute at block termination
falseLogical Boolean false value
for Begin a for loop
ifExecutes the code block in case conditional statement for if is true
inUsed with for loop
moduleDefining a module
nextJump to point immediately before evaluation of loop’s conditional
nilEmpty or invalid or always false
notLogical Negation Operator
orLogical Or Operator
redoJump after a loop conditional
rescueEvaluates the expression after an exception is raised
retry• When called outside of rescue repates the method call
• When called inside rescue jumps to top of block
returnReturns a value from a method or code block
selfCurrent Object
superCalls method of same name in the superclass
thenSeparator used with if, unless, when, case, rescue
trueLogical Boolean true
undefMakes a method/function undefined in current class
untilExecute code block while conditional statement is false
whenStarts a clause under case statement
whileExecutes the code block, until the conditional statement becomes false
yieldExecutes the code block which is passed to a method

These are Reserved Words in Ruby Programming Language, while writing code in Ruby Language just don’t use these words as variables or functions names.

I hope that this article provided you information about Reserved Words in Ruby Programming Language. I have put together many other articles about Python, JavaScript and other programming languages, you can check those articles here – Python Tutorials, JavaScript Tutorials.

Comments to: Reserved Words in Ruby Programming Language

Your email address will not be published.