Skip to content

Coder Tutorial

Menu
  • Home
  • HTML
  • CSS
  • PHP
  • SQL
  • MySQL
  • JS
  • PL/SQL
  • Python
  • Java
  • Oracle
Home
Ruby
Ruby If-Elsif-Else

Ruby If-Elsif-Else

Ruby IF-ELSIF-ELSE

The Ruby IF-ELSIF-ELSE statement syntax and example.

Ruby IF-ELSIF-ELSE syntax

if condition_v1
	-- Ruby code v1
elsif condition_v2
	-- Ruby code v2
else
	-- Ruby code v3
end

Ruby IF-ELSIF-ELSE example

a = 1
b = 2
if a > b
	puts "A is greater than B"
elsif b > a
	puts "B is greater than A"
else
	puts "A is equal to B"
end

Output

B is greater than A

Tutorials

  • Ruby Tutorial
  • Ruby Variables
  • Ruby Strings
  • Ruby Date and Time
  • Ruby Array
  • Ruby Hashes
  • Ruby Ranges
  • Ruby If-Elsif-Else
  • Ruby Case
  • Ruby For Loop
  • Ruby While Loop
  • Ruby Until Loop
  • Ruby Each Loop
  • Ruby Next Statement
  • Ruby Break Statement
  • Ruby Return statement
  • Ruby Methods
  • Ruby Blocks
  • Ruby Exceptions

Recent Posts

  • Java Polymorphism
  • Java Encapsulation
  • Java Abstraction
  • PostgreSQL ERROR: cannot begin/end transactions in PL/pgSQL
  • PostgreSQL Column must appear in the GROUP BY clause
  • PostgreSQL Column specified more than once
  • PostgreSQL Create database, Alter database examples
  • PostgreSQL Create schema syntax, Alter schema
  • PostgreSQL Create database user, alter and drop username
  • PostgreSQL Alter table name. Modify column name
Coder Tutorial Copyright © 2025. | Privacy Policy
Back to Top ↑