This is a very silly question, but it doesn't work for me.
I am trying to make the program wait for my input. I tried replacing gets
with stdin.gets
, and $stdin.gets
and when I try gets.chomp
I get a nil class exception.
puts "Get works here?"
option = gets
puts option
To work this,you need to call your .rb file from your command prompt. Like say you save your code in a file called test.rb
.
test.rb
puts "Get works here?"
option = gets
puts option
Then run from your command prompt:
C:\Users\arup> ruby test.rb
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With