Guest User

Untitled

a guest
Apr 25th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. def a_big_ole_loop_loop
  2. array = ["Dave", "John", "Melissa"]
  3. i = 0
  4. loop do
  5. if i == array.length
  6. break
  7. end
  8. puts "Yo! What up #{array[i]}!? Welcome to the line! You have #{i} person(s) in front of you! Chill out brah..."
  9. i += 1
  10. end
  11. end
  12.  
  13. def the_anticipatory_until_loop
  14. array = ["Dave", "John", "Melissa"]
  15. i = 0
  16. until i == array.length
  17. puts "Yo! What up #{array[i]}!? Welcome to the line! You have #{i} person(s) in front of you! Chill out brah..."
  18. i += 1
  19. end
  20. end
  21.  
  22. def the_infamous_each_loop
  23. array = ["Dave", "John", "Melissa"]
  24. i = 0
  25. array.each do |person|
  26. puts "Yo! What up #{person}!? Welcome to the line! You have #{i} person(s) in front of you! Chill out brah..."
  27. i += 1
  28. end
  29. end
  30.  
  31. def too_many_loops_that_know_too_much
  32. array = [{name: "Dave", age: 34}, {name: "John", age: 22}, {name: "Melissa", age: 45}]
  33. i = 0
  34. array.each do |person|
  35. puts "Yo! What up #{person[:name]}!? Welcome to the line! You have #{i} person(s) in front of you! Also we somehow know that you're #{person[:age]} years old. Chill out brah..."
  36. i += 1
  37. end
  38. end
Add Comment
Please, Sign In to add comment