Thank you for the tip,
That is very elegant,
Mike
···
-----Original Message-----
From: Berger, Daniel [mailto:djberge@qwest.com]
Sent: Tuesday, August 26, 2003 12:49 PM
To: ruby-talk@ruby-lang.org
Subject: Re: Why did you switch from Python to Ruby?
-----Original Message-----
From: Schneider, Michael [mailto:michael.l.schneider@eds.com]
Sent: Tuesday, August 26, 2003 10:25 AM
To: ruby-talk@ruby-lang.org
Subject: Re: Why did you switch from Python to Ruby?
Ruby Issues:
- named parameters (is this in 1.8?), these are really
handy for GUI objects
with many valid options that are partially set by the user.
Easy enough to do as is with a block, provided the package author simply
provides a “yield self if block_given?”.
e.g.
class Foo_Widget
attr_accessor :height, :border, :bgcolor
def initialize
yield self if block_given?
end
end
o = Foo_Widget.new{ |f|
f.height = 10
f.border = 2
f.bgcolor = “red”
}
p o → #<Foo_Widget:0x28ac140 @height=10, @bgcolor=“red”, @border=2>
Regards,
Dan