If
With if
and else
keywords the flow of a program can be controlled.
a="test"
if (a.type() == "STRING")
puts("is a string")
else
puts("is not a string")
end
Output
is a string
Elif
elif
allows providing of an additional consequence check after if
and before evaluating the alternative provided by else
. There is no limit on how many elif
statements can be used.
a = "test"
if (a.type() == "BOOLEAN")
puts("is a boolean")
elif (a.type() == "STRING")
puts("is a string")
else
puts("i have no idea")
end
Output
is a string