Ruby study memo (conditional branching)

Overview

Last time, I studied the most basic variables and functions in programming. This time, the memo of the if else statement used in the conditional branch is described below.


if ~ then
Process 1
elsif ~ then
Process 2
else
Process 3

Is the basic shape

Sample program

I tried to create a program with if else to judge whether that year is the year of the Olympic Games


year = 2021

if year%4 == 0 then
  print("This year is the olympic games")
elsif year == 2021 then
  print("This year is the olympic games(Prolonged by coronavirus)")
else
  print("This year is not the Olympics")
end

reference

https://www.javadrive.jp/ruby/numeric_class/index6.html

Recommended Posts

Ruby study memo (conditional branching)
[Java ~ Conditional branching / Iterative processing ~] Study memo (3)
[Ruby] Conditional branching Conditional expression order
Ruby study memo (recursive function)
[Ruby ~ Iterative processing ~] Study memo 4
Ruby memo
Ruby Study Memo (Test Driven Development)
Java study # 4 (conditional branching / if statement)
[wip] Ruby memo
Ruby conditional branch processing
ruby basic syntax memo
[Java ~ Method ~] Study memo (5)
Program using conditional branching
Ruby study notes (puts)
Dot installation study memo 01
Conditional branching of numbers
[Java ~ Array ~] Study memo 4
Also complicated conditional branching
[Ruby] How to use standard output in conditional branching
Play Framework Study Memo Database ①
Java conditional branching: How to create and study switch statements
Java Silver Study Method Memo
[Self-use memo] (Ruby) class, class instance, instance
Personal memo Progate Ruby I (2)
[Java ~ Boolean value ~] Study memo (2)
Introduction to JUnit (study memo)
[Ruby] Conditional bifurcation unless statement
A little complicated conditional branching
Java study memo 2 with Progate
java (conditional branching and repetition)
Personal memo Progate Ruby I (1)
Ruby study notes (variables & functions)
ruby exercise memo I (puts)
[Ruby] conditional branch if statement
Basics of conditional branching and return
Play Framework Study Memo Database ②Read
ruby exercise memo VI (hello class)
Conditional branching with a flowing interface
spring framework Simple study memo (2): AOP
[Study session memo] Java Day Tokyo 2017
Ruby on Rails 6.0 environment construction memo
String output method memo in Ruby
[Note] [Beginner] Ruby writing memo (refactoring) 1