Created
March 29, 2017 08:54
-
-
Save fractalatcarf/adcbe23477a816d9d817cd68b135a211 to your computer and use it in GitHub Desktop.
live code de ce matin, IF, FOR, ARRAY & ARRAY.EACH
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 can_vote?(age=20) | |
# # # ## age == 18 | |
# # # return true if age > 17 | |
# # # return false | |
# # # end | |
# # # # # age = 17 # affectation | |
# # # # # condition = can_vote?(age) | |
# # # # # if condition | |
# # # # # puts "you can vote" | |
# # # # # else | |
# # # # # puts "you can't vote" | |
# # # # # end | |
# # # # # if !condition | |
# # # # # puts "you can't vote" | |
# # # # # else | |
# # # # # puts "you can vote" | |
# # # # # end | |
# # # # # unless condition | |
# # # # # puts "you can't vote" | |
# # # # # else | |
# # # # # puts "you can vote" | |
# # # # # end | |
# # # # # # age = 18 | |
# # # # # # if age == 18 | |
# # # # # # puts "welcome in the adult wordl" | |
# # # # # # elsif age < 18 | |
# # # # # # puts "you can't vote" | |
# # # # # # elsif age > 17 | |
# # # # # # puts "can vote" | |
# # # # # # end | |
# # # # coins = ["heads", "tails"] | |
# # # # response = nil | |
# # # # until coins.include?(response) || response == "" | |
# # # # puts "heads or tails ?" | |
# # # # print "> " | |
# # # # response = gets.chomp | |
# # # # end | |
# # # # coin = coins.sample | |
# # # # if response != "" | |
# # # # puts (response == coin ? "you win" : "you lose, it was #{coin}") | |
# # # # # if response == coin | |
# # # # # puts "you win" | |
# # # # # else | |
# # # # # puts "you lose, it was #{coin}" | |
# # # # # end | |
# # # # end | |
# # # puts "say hello in your language" | |
# # # print "> " | |
# # # response = gets.chomp | |
# # # # case response | |
# # # # when "Hi" | |
# # # # puts "you are american" | |
# # # # when "Ola" | |
# # # # puts "you are spanish" | |
# # # # when "Bonjour" | |
# # # # puts "you are french" | |
# # # # else | |
# # # # puts "?" | |
# # # # end | |
# # # puts "you are american" if response == "Hi" | |
# # # puts "you are spanish" if response == "Ola" | |
# # # puts "you are french" if response == "Bonjour" | |
# # hour = 24 | |
# # if (hour > 9 && hour < 12) || (hour > 14 && hour < 18) | |
# # puts "open" | |
# # else | |
# # puts "close" | |
# # end | |
# sum = "" | |
# for num in ["a", "b", 2] | |
# # puts num | |
# sum = sum + num | |
# end | |
# puts sum | |
empty_array = [] | |
beatles = ["john", "ringo", "seb", "seb"] | |
# puts beatles[2] | |
# p beatles | |
# beatles[2] = "Kevin" | |
# p beatles | |
beatles[0...-2].each do |item| | |
puts item | |
end | |
# p beatles | |
# # puts beatles.size | |
# # puts beatles.length | |
# # puts beatles.count | |
# beatles << "ariane" | |
# p beatles | |
# beatles.delete("seb") | |
# p beatles | |
# beatles.delete_at(1) | |
# p beatles | |
# beatles.insert(1, "ringo") | |
# p beatles | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment