Sublime Forum

Newbie Question

#1

Hi all,

I have decided to teach myself programming and purchased a book named ‘learn to program’ and in this it teaches Ruby. I have been using Sublime without the built the built in console to test my code.

It’s not possible to add numbers and strings (2+house means nothing) need to convert them both to the same type

var1 = 2
var2 = ‘5’

.to_i gives the integer version of an object, and .to_f gives the float version

puts var1.to_s + var2
puts var1 + var2.to_i

and all was working fine until I got to the next chapter in the book says

If puts means put string, I’m sure you can guess what gets stands for. And just as puts always spits out strings, gets retrieves only strings. And whence does it get them?
From you! Well, from your keyboard, anyway. And since your key- board makes only strings, that works out beautifully. What actually happens is that gets just sits there, reading what you type until you press Enter .
Let’s try it:

puts gets

Is there an echo in here?
Is there an echo in here?

but when I type in puts gets, then build nothing happens. Do I have to run my code in terminal or is there a way in sublime for me to test the code and see if ‘gets’ is working?

0 Likes

#2

The build cannot be interactive. Maybe have a look to the plugin SublimeREPL (never tried it but it might fit your need). Otherwise, yes you have to run it in a terminal.

0 Likes