From: Brian Candler Date: 2011-05-24T17:12:24+09:00 Subject: Re: Generating Functions in Ruby Andreas Lundgren wrote in post #1000537: > The line > params_2 = #{params}; > extends to: > params_2 = x1.to_s + ', ' + x2.to_s + ', ' + x3.to_s + ', ' + x4.to_s Or you could do it like this: params_2 = "#{x1}, #{x2}, #{x3}, #{x4}" #{} interpolates the value of an expression into a string and calls to_s automatically. A slightly more DRY version: params_2 = [x1, x2, x3, x4].join(", ") Again, to_s is called automatically in this case. Finally, if you used the *args syntax to collect a variable number of args into an array, then it would become params_2 = args.join(", ") or even just: handle.call(['MethodNameIn','Params'],[method]+args) > Output from the function when STUB_CALLS=1: Tiny suggestion: STUB_CALLS = false / true would be clearer, because then you could say do_something if STUB_CALLS rather than do_something if STUB_CALLS != 0 A global variable ($stub_calls) would arguably be preferable, since you can change it at runtime without generating a warning. And better again would be an instance variable of a class or module, because then it lives in its own namespace. module MyStuff @stub_calls = false # set the default def self.stub_calls @stub_calls end def self.stub_calls=(x) @stub_calls = x end end puts MyStuff.stub_calls MyStuff.stub_calls = true puts MyStuff.stub_calls Another thing to look at is using heredoc, as it means you don't have to worry about quoting double-quotes: class <