[Win32utils-devel] Trivial API question

win32utils-devel at rubyforge.org win32utils-devel at rubyforge.org
Thu Feb 26 13:59:15 EST 2004

I know - I like to futz.  I'm thinking of changing the way I pass
optional arguments.  This is from EventLog:

# Write an event to the event log

# Current way
   "source"   => "foo",
   "category" => 0x2,
   "event_id" => 0x3,
   "data"     => "Warning! Danger Will Robinson!",
   "type"     => EventLog::WARN

# Proposed way	
el.report_event{ |e|
   e.source		= "foo"
   e.category	= 0x2
   e.event_id	= 0x3
   e.data		= "Warning! Danger Will Robinson!"
   e.type		= EventLog::WARN

This looks a little "cleaner" I think and is a bit more Ruby-ish.  It
would use a yielded struct, which has an advantage over a hash - you
can't pass a bogus key, i.e. builtin validation.

What do you think?  Or should I just leave it alone?


More information about the win32utils-devel mailing list