Hi I am making a simple ruby script practiced where I make a form using gets.chomp and arguments, the problem is that when gets.chomp use the script returns me an error when I apply the argument test.The code:#!usr/bin/rubydef formulario(quien) while (1) print "[+] Word : " word = gets.chomp print quien + " -> " + word endendquien = ARGV[0]formulario(quien)The error:[+] Word : C:/Users/test/test.rb:8:in `gets': No such file or directory @ rb_sysopen - test (Errno::ENOENT) from C:/Users/test/test.rb:8:in `gets' from C:/Users/test/test.rb:8:in `formulario' from C:/Users/test/test.rb:17:in `<main>'Can anyone help? 解决方案 It looks like you want to the user to type some input by reading a line from STDIN, the best way to do this is by calling STDIN.gets and not gets. So your line becomes:word = STDIN.gets.chompThis is documented as IO.gets. STDIN is an instance of IO.Right now, you're executing Kernel.gets, which does something different (emphasis mine):This appears to behave like STDIN.gets if ARGV is empty, but is not the same thing, hence the confusion. 这篇关于使用gets() 给出“没有这样的文件或目录";将参数传递给脚本时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-23 18:25