0

I'm tried these ruby code lines to run in sublimeText3 but I dont get any error even in view ->show console. Show result shows me that the coding is building, but I couldn't see any output there. The below code is what I'm trying.

guess.rb

words = ['foobar', 'baz', 'quux']
secret = words[rand(3)]

print "guess? "
while guess = STDIN.gets
  guess.chop!
  if guess == secret
    puts "You win!"
    break
  else
    puts "Sorry, you lose."
  end
  print "guess? "
end
puts "The word was ", secret, "."
trying...
  • 309
  • 1
  • 11

1 Answers1

0

Since the Sublime Text console does not accept any input, you need to install package like SublimeREPL. You can launch it from Tools > SublimeREPL > Ruby.

idleberg
  • 12,634
  • 7
  • 43
  • 70
  • I have installed that package into the sublimetext3 folder but still Im unable to see the launch session you said – trying... Sep 28 '16 at 13:24
  • What do you mean by “installed into the Sublime Text folder”? Package Control is the recommended way to install packages, just follow the steps described in [instructions](https://github.com/wuub/SublimeREPL#installation). – idleberg Sep 28 '16 at 13:27
  • Im getting this error in tools -> SublimeREPL, `to_specs': Could not find 'pry' (>= 0) among 9 total gem(s) (Gem::LoadError) – trying... Sep 28 '16 at 13:30
  • Well, just install Pry then: `sudo gem install pry`. You should probably make your Ruby homework before diving deep into it. – idleberg Sep 28 '16 at 13:31
  • I get a new error after insatlling pry gem, `
    ': uninitialized constant Pry::InputCompleter (NameError)
    – trying... Sep 28 '16 at 13:37
  • You should probably start a new question for your new problem – idleberg Sep 28 '16 at 13:38
  • 1
    Take a look at this [issue](https://github.com/wuub/SublimeREPL/issues/336) on GitHub, installing these version will fix your NameError – idleberg Sep 28 '16 at 13:49