R
Richard
Hi All,
In the appended code I duplicate the text so I can both display it and
define a new Proc. Is there away I can use, say,
text = '[*1..n].join(", ")'
in the body of the Proc spec. and thus simply
puts text?
Thanks in advance,
Richard
def example(n)
return Proc.new { [*1..n].join(", ")}
end
puts %q![*1..n].join(", ") ! + " #=>"
puts example(3).call # => 1, 2, 3
In the appended code I duplicate the text so I can both display it and
define a new Proc. Is there away I can use, say,
text = '[*1..n].join(", ")'
in the body of the Proc spec. and thus simply
puts text?
Thanks in advance,
Richard
def example(n)
return Proc.new { [*1..n].join(", ")}
end
puts %q![*1..n].join(", ") ! + " #=>"
puts example(3).call # => 1, 2, 3