Created
October 19, 2016 20:02
-
-
Save kajatiger/3d7036b3247c967275a61cb95b7c36e6 to your computer and use it in GitHub Desktop.
conditional ruby blocks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (5+5==10) | |
puts "this is true" | |
else | |
puts "this is false" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def choose | |
puts "do you like programming? yes or no or maybe please" | |
choice = gets.chomp | |
case choice.downcase | |
when "yes" | |
puts "that\'s great!" | |
when "no" | |
puts "that\'s too bad" | |
when "maybe" | |
puts "Glad you are giving it a chance!" | |
else | |
puts "that wasn\'t a yes or no or maybe" | |
end | |
end | |
choose | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 3.times do | |
# puts "hello!" | |
# end | |
# number = 0 | |
# while (number <= 10) do | |
# p "the number is now #{number}" | |
# number += 1 | |
# end | |
(0..10).each do |n| | |
p "the number is #{n}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment