From: Gennady Bystritsky Date: 2010-06-08T07:27:10+09:00 Subject: Re: Please explain this "Why's" example please On Jun 6, 2010, at 12:20 AM, Kaye Ng wrote: > I'm reading Why's Poignant Guide to Ruby. > > I don't understand this example. > -------------------------------------------------------- > require 'wordlist' > > # Get evil idea and swap in code words > > print "Enter your new idea: " > > idea = gets > > code_words.each do |real, code| > idea.gsub!( real, code ) > end > --------------------------------------------------------- > I'm assuming that, if I run the program, there would be a message on the > screen that says "Enter your new idea:" and a text box for me to type > something. > > After I type a word (and press an 'OK' button?), then what? Can anyone > explain to me the role of Gets here? And also the Each block please. You > may also give me another example with Gets and Each. Not everything in this world are text boxes and buttons ;-) -- there are good ol' input and output streams (character based) that are dealt with by means of print, puts, gets and other methods of Ruby class IO. On Windows, which is most likely what you use, it is something you would see in and enter from a cmd.exe window (sometimes called Console). Gennady.