SHARE
TWEET

Test Each Loop

a guest Dec 4th, 2012 12 Never
  1. def inexpensive
  2.   ["a","b","c"]
  3. end
  4.  
  5. def expensive
  6.   sleep(1)
  7.   ["a","b","c"]
  8. end
  9.  
  10. puts "fast"
  11. inexpensive.each do |item|
  12.   puts item
  13. end
  14. puts "slow?"
  15. expensive.each do |item|
  16.   puts item
  17. end
  18.  
  19. puts "will this run forever?"
  20. myArr = ["a","b","c"]
  21. myArr.each do |item|
  22.   myArr.push("x")
  23. end
RAW Paste Data
Top