filename = ARGV.first
txt = open(filename)
puts "Here's your file #{filename}:"
print txt.read
print "Type the filename again: "
file_again = $stdin.gets.chomp
Here is my question if I change it to gets.chomp
it doesn't work why ?
txt_again = open(file_again)
print txt_again.read
What's the difference between gets.chomp
and $stdin.chomp
Per the Kernel#gets docs (emphasis mine):
In your case, ARGV is non-empty, so
Kernel#gets
applies to it: