Answer the question
In order to leave comments, you need to log in
How to fix the problem with opening a txt file?
This code easily opens the f.txt file and writes the keys to a separate array. The f.txt file contains no more than 10 lines.
c = Hash[*File.read('f.txt', encoding: "utf-8").split(/[:: :: \n]+/)]
n = c.each_key.to_a
puts n
tut.rb:13:in `[]': odd number of arguments for Hash (ArgumentError)
from tut.rb:13:in `'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question