Advertisement
Guest User

Untitled

a guest
Feb 29th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.37 KB | None | 0 0
  1.  
  2. # NOTE: each following line was performed in sequence via irb.
  3. # test is an array
  4. >> test
  5. => ["a", "b", "a"]
  6.  
  7. # this prints out the result of the count method
  8. >> test.count("a")
  9. => 2
  10.  
  11. # BUT this does not! WHY? Is it some irb anomaly?
  12. >> test.each do |k|
  13. ?> test.count("a")
  14. >> end
  15. => ["a", "b", "a"]
  16.  
  17.  
  18. >> test.each do |k|
  19. ?> puts test.count("a")
  20. >> end
  21. 2
  22. 2
  23. 2
  24. => ["a", "b", "a"]
  25. >>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement