From: James Coglan Date: 2008-09-08T19:11:27+09:00 Subject: Re: Hash auto-true ({:a} == {:a => true}) ------=_Part_3773_2435589.1220869056100 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline > > Now I'm wondering what it would take to define a hash explode (sidenote: > is that what * on *args is called? explode?). How would one go about > defining something like {}args that explodes args into a > true-for-value-less hash (even using the code you posted)? I'm not sure > exactly how *args works internally, and it's pretty hard to find info > about it, actually. Any idea what kind of method it is, and how would > you define another one? Far as I know, the *args is part of Ruby's syntax, it's not a method that you can change. Even if you could change it, I've no idea which class the method would be in. The best you can do is use *args to mean "the remaining args" and pop the last one off if it's a hash. You could add a method in Hash to set one value to many keys: class Hash def set_many(value, *keys) keys.each { |key| self[key] = value } end end Then do the following: def my_method(arg1, arg2, *args) options = (Hash === args.last) ? args.pop : {} options.set_many(true, *args) # ... end ------=_Part_3773_2435589.1220869056100--