Hi,
I am just starting Ruby as my first programming language. I have this
version installed on my Linux: ruby 1.9.3p194
While reading this book, I tried this example:
wordlist.rb:
code_words = {
'Milkshake' => 'See what you mean to me, sweet cakes and milkshakes',
'Strawberry' => 'People moving all the time, inside a perfectly
straight line, don't you wanna curve away?'
}
and code.rb has:
require 'wordlist'
# Get the 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
# Save the jibberish to a new file
print "File encoded, Please enter a name for this idea: "
idea_name = gets.strip
File::open ( "idea-" + idea_name + ".txt", "w" ) do |f|
f << idea
end
···
--------------------------
Running code.rb gives errors:
./code.rb:13: syntax error, unexpected ',', expecting ')'
File::open ( "idea-" + idea_name + ".txt", "w" ) do |f|
^
./code.rb:13: syntax error, unexpected ')', expecting $end
File::open ( "idea-" + idea_name + ".txt", "w" ) do |f|
^
Any help would be great.
--
Posted via http://www.ruby-forum.com/.