Forum: Ruby Re: Hash#getopt

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
F3b7b8756d0c7f71cc7460cc33aefaee?d=identicon&s=25 Berger, Daniel (Guest)
on 2006-04-26 15:51
(Received via mailing list)
> >
> > h.ignore_key_case = true # or whatever
> globally for hashes requires a good bit of code to make
> by sticking to access of options only it's possible to
> provide an easy way to do the normal thing in 98% of cases.
> as the above two examples show though, a more general
> approach involves making lots of choices about string/symbol
> interaction.  i actually do this in my own code but it's
> slippery and not for general consumption.

I thought AOP might be appropriate here, but I couldn't make it work:

require 'aspectr'
include AspectR

class SymAspect < Aspect
   def pre(method, object, exit_status, *args)
      puts "In the pre method"!{ |arg| arg.to_s.downcase }
end, :pre, nil, :[])
h = {'foo', 1, 'bar', 2}
h['foo'] # nothing - why?

(I posted a similar question on c.l.r. via Google Groups, btw)

Regardless of whether or not this is a bug, what do you think of AOP
as an approach to this issue?



This communication is the property of Qwest and may contain confidential
privileged information. Unauthorized use of this communication is
prohibited and may be unlawful.  If you have received this communication
in error, please immediately notify the sender by reply e-mail and
all copies of the communication and any attachments.
This topic is locked and can not be replied to.