Created
May 14, 2015 10:45
-
-
Save volpeo/bcebf36874cead3b09ed to your computer and use it in GitHub Desktop.
Iterator Blocks - cours
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
films = [ | |
"Le parrain", | |
"Star Wars", | |
"Mars Attack", | |
"Django" | |
] | |
films << "Les dents de la mer" | |
films[1] = "Star Wars La menace fantôme" | |
# puts films[2..3] | |
# p films[2..3] | |
# age = 28 | |
# p "J'ai #{age} ans" | |
# p "J'ai " + age.to_s + " ans" | |
# for film in films | |
# p film | |
# end | |
# for index in 0...films.size | |
# p "#{index+1} - #{films[index]}" | |
# end | |
# films.each_with_index do |movie, position| | |
# p "#{position+1} - #{movie}" | |
# end | |
# p films | |
# promo_films = films.map! do |movie| | |
# "#{movie.upcase} - promo" | |
# end | |
# promo_films = films.map { |movie| "#{movie.upcase} - promo" } | |
# l_films_count = promo_films.count do |movie| | |
# movie[0].downcase == "l" | |
# end | |
# short_films_count = films.count do |movie| | |
# movie.size < 15 | |
# end | |
# short_films = films.select do |movie| | |
# movie.size < 15 | |
# end | |
def timer | |
start_time = Time.now | |
yield | |
time_elapsed = Time.now - start_time | |
end | |
time_taken = timer() do | |
sleep(3) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment