Advertisement
urbanslug

about_sandwich.rb

Oct 29th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. # -----------------------------------------------------
  2. # example_file.txt
  3. # -----------------------------------------------------
  4.  
  5. this
  6. is
  7. a
  8. test
  9.  
  10. # -----------------------------------------------------
  11. # about_sandwich_code.rb
  12. # -----------------------------------------------------
  13.  
  14. def find_line2(file_name)
  15. lines = []
  16. File.open(file_name) do |file|
  17. while each_line = file.gets
  18. lines << each_line
  19. end
  20. end
  21. lines[2]
  22.  
  23. end
  24.  
  25. def test_finding_lines2
  26. assert_equal "is\n", find_line2("example_file.txt")
  27. end
  28.  
  29. # -----------------------------------------------------
  30. # The error
  31. # -----------------------------------------------------
  32.  
  33. undefined local variable or method `lines' for #<AboutSandwichCode:0x7f47741c6ac0>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement