Академический Документы
Профессиональный Документы
Культура Документы
"
GLOSSARY
if
elsif
else
while
until
.length
.reverse
.uppercase
.lowercase
.capitalize <---- adds capital letter and converts the rest to lowercase
.each <---------- selects each string in an array ex: if my_array = [1, 2, 3] then
my_array.each selects [1, 2, 3] each turns individually.
.times <-------- multiplys by any given number ex: 30.times { print my_var }
.split <-------- my_var.split //// splits each word of a string into separate
blocks.
-----------------------------------------------------------------------------------
------
-----------------------------------------------------------------------------------
--------
first_name = gets.chomp
first_name.capitalize!
print "your surname?"
last_name = gets.chomp
last_name.capitalize!
puts "Hi #{first_name}, your surname is #{last_name} and you live in #{city}. You
come from #{state}."
---------------------------------------------------
Loop i to 5
i = 0
while
i < 5
puts i
i = i + 1
end
---------------
This prints i from 20 down to 0, jumping uneven numbers with the [next] function,
next if i % 2 != 0 <----------- remainder
i = 20
loop do
i -= 1
next if i % 2 != 0
puts "#{i}"
break if
i == 0
end
RAILSRAILSRAILSRAILSRAILSRAILSRAILSRAILSRAILSRAILSRAILSRAILSRAILSRAILSRAILSRAILSRAI
LSRAILSRAILSRAILSRAILSRAILSRAILSRAILSRAILSRAILSRAILSRAILSRAILSRAILSRAILSRAILSRAILSR
AILSRAILSRAILSRAILSRAILSRAILSRAILS