From: Dan Doel [mailto:djd15@po.cwru.edu]
Sent: Wednesday, August 27, 2003 1:46 AM
To: ruby-talk@ruby-lang.org
Subject: Blocks, eval and named parameters
Anyhow, any thoughts on all this? Thanks in advance for the
stuff I’ll
probably learn from any discussion
that ensues.
It’s been discussed on RubyGarden to some degree. See
Regards,
Dan
···
-----Original Message-----
Dan_Doel
(Dan Doel)
2
Berger, Daniel wrote:
It’s been discussed on RubyGarden to some degree. See
http://www.rubygarden.org/ruby?KeywordArguments
Thanks for the link, but it doesn’t seem to answer my question at all
(which was about
passing a block to #eval and such).
I guess I should ramble a bit less in my posts.
Hal introduced the following technique in his presentation at the
Euruko
(http://hypermetrics.com/rubyhacker/euruko03/rubyesque/slide7.html)
class A
attr_writer :foo
def initialize
yield self
class << self; private :foo; end
end
end
to avoid leaving accessors after instantiation.
You could generalize this as follows:
def foo
s = Struct.new(:param1, :param2, :etc)
yield s
# do things with s.param1, s.param2, s.etc
end
foo do |p|
p.param1 = :bla
p.param2 = “foo”
p.etc = [‘bar’, ‘baz’]
end
···
On Thu, Aug 28, 2003 at 05:13:37PM +0900, Dan Doel wrote:
Berger, Daniel wrote:
It’s been discussed on RubyGarden to some degree. See
http://www.rubygarden.org/ruby?KeywordArguments
Thanks for the link, but it doesn’t seem to answer my question at all
(which was about
passing a block to #eval and such).
–
_ _
__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_
_ \ / ` | ’ \
) | (| | |__ \ | | | | | (| | | | |
.__/ _,|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com
Sorry. I just realized this sentance makes no sense
– Ian Main
dhtapp
(dhtapp)
4
What a thoroughly useful set of slides for a newbie. And, as a bonus, an
introduction to his writing style…now I know I want the book
“Mauricio Fernández” batsman.geo@yahoo.com wrote in message
news:20030828093315.GB12453@student.ei.uni-stuttgart.de…
···
Hal introduced the following technique in his presentation at the
Euruko
(http://hypermetrics.com/rubyhacker/euruko03/rubyesque/slide7.html)
HAL_9000
(HAL 9000)
5
dhtapp wrote:
What a thoroughly useful set of slides for a newbie. And, as a bonus, an
introduction to his writing style…now I know I want the book
Thanks. That kind of comliment makes it worthwhile.
Hal
···
“Mauricio Fernández” batsman.geo@yahoo.com wrote in message
news:20030828093315.GB12453@student.ei.uni-stuttgart.de…
Hal introduced the following technique in his presentation at the
Euruko
(http://hypermetrics.com/rubyhacker/euruko03/rubyesque/slide7.html)