a , b =ARGV
puts "the script is called:#{$0}"
print "adsfa?"
d = gets.chomp()
# d = $stdin.gets.chomp()
puts "This is from your .gets:#{d}"
puts "This is from ARGV a:#{a}"
puts "This is from ARGV b:#{b}"
D:\rubylearn> ruby ex7.rb
the script is called:ex7.rb
adsfa?qwerThis is from your .gets:qwerThis is from ARGV a:This is from ARGV b:
D:\rubylearn> ruby ex7.rb 1 2
the script is called:ex7.rbadsfa?ex7.rb:6:in `gets': No such file or directory - 1(Errno::ENOENT)from ex7.rb:6:in `gets' from ex7.rb:6:in `'
input = $stdin.gets
a , b = ARGVputs "the script is called:#{$0}"print "adsfa?"d = $stdin.gets.chomp()puts "This is from your .gets:#{d}"puts "This is from ARGV a:#{a}"puts "This is from ARGV b:#{b}"
D:\rubylearn> ruby ex7.rb
the script is called:ex7.rb
adsfa?qwerThis is from your .gets:qwerThis is from ARGV a:This is from ARGV b:
联系客服