K
Kaye Ng
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.
Explain it to me as if I'm a moron please. No big words, no complicated
programming terms, none of that. I'm a beginner.
Thanks so much for your time. =)
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.
Explain it to me as if I'm a moron please. No big words, no complicated
programming terms, none of that. I'm a beginner.
Thanks so much for your time. =)