From: Robert Klemme Date: 2006-03-08T20:08:41+09:00 Subject: Re: Having a block executed in the context of an instance Mike Austin wrote: > Thanks, that works well. But as you note, prepending 'self' kind of > defeats the purpose ;) Is there a way to make Ruby not create local > variables, but use 'local var' or similar? No, there isn't. However, often using a hash as argument solves this problem: class Foo def initialize(h={}) h.each {|var,val| send("#{var}=", val)} end end Foo.new( :caption => 'Click me', :color => :orange, :size => 42 ) With a bit more code you can even have default values. Kind regards robert