Answer the question
In order to leave comments, you need to log in
Why doesn't the gets method work in Sublime Text 3?
In irb the gets method works, but in Sublime Text 3 there is no response. chomp is not defined at all.
Here is an example code:
name = gets.chomp
print name
Answer the question
In order to leave comments, you need to log in
By default, Sublime Text doesn't have a terminal, so when you run a build, it executes the entire script and simply displays the result of the entire execution in the build window. Interactive data entry from there is not supported.
However, there is SublimeREPL, a plugin for Sublime Text that adds the ability to execute code without leaving the editor. Installed like any other Sublime Text plugin (don't forget to restart ST after installing the plugin):
The plugin should pick up and use the current active version of ruby, including rvm and rbenv. Ruby requires the pry gem to be installed (there may be problems with the latest pry, in which case it is advised to install pry version 0.9.12.6):
$ gem install pry
# или
$ gem install pry -v 0.9.12.6
name = STDIN.gets.chomp
# или
name = $stdin.gets.chomp
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question