Re: Hash#getopt

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 G., 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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs