Ruby is a programming language that allows you to write code in a variety of ways. You can use if, else if, and while commands to control the flow of your code. If you want to test your code before you deploy it, you can use the Rubinius gem to do so. This gem will run all your tests and report back on their results in a format that you can read.


If syntax

If Else Syntax

If Else If Syntax

Here’s the key difference between Ruby and most other languages. Note that “else if” is actually spelled “elsif” without the e.

Ternary (shortened if statement) Syntax

Ternary syntax is the same in Ruby as most languages. The following sample will print “The variable is 10” if var is equal to 10. Otherwise it will print “The variable is Not 10”.