Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -----------------------------------------------------
- # example_file.txt
- # -----------------------------------------------------
- this
- is
- a
- test
- # -----------------------------------------------------
- # about_sandwich_code.rb
- # -----------------------------------------------------
- def find_line2(file_name)
- lines = []
- File.open(file_name) do |file|
- while each_line = file.gets
- lines << each_line
- end
- end
- lines[2]
- end
- def test_finding_lines2
- assert_equal "is\n", find_line2("example_file.txt")
- end
- # -----------------------------------------------------
- # The error
- # -----------------------------------------------------
- undefined local variable or method `lines' for #<AboutSandwichCode:0x7f47741c6ac0>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement