Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. def test(name)
  2. names = %w(one two three four)
  3. names.each do |name|
  4. puts name
  5. end
  6. puts name
  7. end
  8.  
  9.  
  10. test 'zero'
  11.  
  12. #out
  13. one
  14. two
  15. three
  16. four
  17. four #this is correct? should be zero
  18.  
  19. x = 10
  20. (1..10).each { |y| print x+y, " "}
  21. #=> 11 12 13 14 15 16 17 18 19 20
  22.  
  23. v = "my value"
  24. (1..3).each do {|n; v| v = n; puts v }
  25. # => 1
  26. # => 2
  27. # => 3
  28. puts v #=> "my value"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement