Ruby doesn't recognize gets.chomp, I think?

I am new to programming and started working with Ruby through the book Learn Ruby The Hard Way. I am in exercise 13, and I just messed around using ARGV and I get .good in the same script. My code is as follows:

first, second, third = ARGV

puts "Your first variable is: #{first}"
puts "Your second variable is: #{second}"
puts "Your third is: #{third}"

print "Was that so difficult?"
answer = gets.chomp
print answer

Obviously, this is not so difficult for the script, but when I run it, I get this error all the time: "ex13.rb: in 'gets": there is no such file or directory @rb_sysopen -' then then prints the first argv user enters when running script '(Errno :: ENOENT) from ex13.rb: 8: in' gets' from ex13.rb: 8: in "

Any help would be greatly appreciated.

+4
source share
1 answer

- , gets . Quoting: "(gets) ( $_) ARGV ( $*) , ."

$stdin.gets , ARGV : ARGV.clear gets.

+5

All Articles