Closest I can get is :
require ‘ostruct’
def announce args
parameterise( args, :age=>21 ) do |template|
“My name is #{template.first} #{template.last} and my age is
#{template.age}”
end
end
def parameterise args, defaults, &block
args = defaults.update args
template = OpenStruct.new( args )
block.call( template )
end
puts announce( {:first=>‘John’, :last=>‘Smith’} )
David
http://homepages.ihug.com.au/~naseby/
···
-----Original Message-----
From: Dennis Misener [mailto:dm@accesscable.net]What I desire is an implementation for “parameters” such that:
def announce(args)
parameters(args,:age=>21)
“My name is #{first} #{last} and my age is #{age}”
endannounce(:first=>‘John’, :last=>‘Smith’) generates
“My name is John Smith and my age is 21”