D
D
Dmitry Vladimirovich Speaker2018-04-01 20:44:16
ruby
Dmitry Vladimirovich Speaker, 2018-04-01 20:44:16

How to prevent Ruby console from closing after executing code?

Greetings. Began to study Ruby, there was a corresponding question.
How can I make the Ruby console not close after executing the code, but remain open until a certain key is pressed (For example, Enter)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Karim Kyatlottyavi, 2018-04-02
@constXife

print 'Введите что-нибудь: '

t = STDIN.gets

puts "Вы ввели: #{t}"

You can also play around with a powerful gem - https://github.com/piotrmurach/tty-prompt /4190379

S
Sergey Blokhin, 2018-04-01
@TITnet

What do you mean by "Ruby console"?
By default, there are two tools for working with Ruby.
Ruby is an Interpreted object-oriented scripting language that executes code from a .rb text file.
Of course, after executing the code, such an interpreter will complete its work.
IRB -- Interactive Ruby Shell. An interactive console where code executes line by line as you type code.
You can end the console manually (ctrl+c) or through the commands exit, abort, etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question