I want to open file and read it that I pass from console.
Like
filename = gets()
File.open(filename,'r') do |file|
but getting error like following on console:
test.rb:7:in `initialize': Invalid argument - myfile (Errno::EINVAL)
from test.rb:7:in `open'
from test.rb:7
Is it possible to read file having filename taken from console and perform do |file| ..end in ruby?
String you read from the STDIN has a trailing
\n. Get rid of it.