The gets Method

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 keyboard 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?

Of course, whatever you type will just get repeated back to you. Run it a few times, and try typing different things.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.215.117