Prev: Launching a commamd prompt window from .rbw application
Next: Ocra: "Failed to create directory"
From: John Wu on 24 Feb 2010 10:18 Hey, I am new to ruby. I have the following simple ruby script def make_show_name(show) return Proc.new {|host| show + " with " + host} end show = make_show_name("Practical Cannibalism") show.call("H. Annabellector") when run this using irb, it prints out: Practical Cannibalism with H. Annabellector but when I saved this as test.rb and type ruby test.rb, it prints out nothing. What is the problem here? Thanks! -- Posted via http://www.ruby-forum.com/.
From: Jean-Julien Fleck on 24 Feb 2010 10:48 Hello, > I am new to ruby. I have the following simple ruby script > def make_show_name(show) > return Proc.new {|host| show + " with " + host} > end > show = make_show_name("Practical Cannibalism") > show.call("H. Annabellector") > > when run this using irb, it prints out: Practical Cannibalism with H. > Annabellector > but when I saved this as test.rb and type ruby test.rb, it prints out > nothing. > > What is the problem here? irb automaticaly prints out the value of the last expression, but your script does not. Try puts show.call("H. Annabellector") and it should be fine. Cheers, -- JJ Fleck PCSI1 Lycée Kléber
|
Pages: 1 Prev: Launching a commamd prompt window from .rbw application Next: Ocra: "Failed to create directory" |