# Re: Hash#getopt

**URL:** <https://www.ruby-forum.com/t/re-hash-getopt/58849>\
**Category:** Ruby\
**Created:** [April 26, 2006, 3:51pm UTC](https://www.ruby-forum.com/t/re-hash-getopt/58849 "2006-04-26T15:51:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [April 26, 2006, 3:51pm UTC](https://www.ruby-forum.com/t/re-hash-getopt/58849/1 "2006-04-26T15:51:19Z")

</div>

> > 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”  
args.map!{ |arg| arg.to\_s.downcase }  
end  
end

SymAspect.new.wrap(Hash, :pre, nil, :[])  
h = {‘foo’, 1, ‘bar’, 2}  
h[‘foo’] # nothing - why?

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

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

Regards,

Dan

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