Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Test Each Loop

By: a guest on Dec 4th, 2012  |  syntax: Ruby  |  size: 0.30 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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