Ruby Fundamentals

Richard Chea
1 min readJan 4, 2021

--

Ruby is a programming language that focuses on simplicity and productivity. It can be said that Ruby is easier to read and write because it seems more “natural”.

Variables

first_name = John
last_name = Smith

The above example is how you would assign a value to a variable. There are also some other data types that can be seen below

# booleans
true_boolean = true
false_boolean = false
# string
new_string = "String Value"
# symbol
a_symbol = :symbol_here
# float
float_value = 1.99

Control Flow: Conditional Statements

if 1 < 2
puts "1 is less than 2"
end

The above statement is a conditional statement that will print out the string because 1 is less than to, which makes that statement true.

Looping/Iterator

num = 1

while num <= 10
puts num
num += 1
end

This example shows a while loop. The initial starting value is 1 and if it’s less than or equal to 10 then it will print out that number. After it does that, it will increment the value and continue on until it gets to 11 and then it will stop.

This is a good intro to data types, conditional statements, and loops. Feel free to check out the main Ruby site for more detailed information.

--

--

No responses yet