*args to Hash

def foo(*args)
h = (Hash === args.last ? args.pop : {})
args.each{|m| h[m]=m}
args = h
#…
end

T.

Trans wrote:

def foo(*args)
h = (Hash === args.last ? args.pop : {})
args.each{|m| h[m]=m}
args = h
#…
end

T.

GOLF.

T.

On 10/10/06, Trans [email protected] wrote:

T.

GOLF.

T.

“args.last ?”.sub(/.l…/, “[-1]”) ==> -2

Most other WS can go away anyway so I guess you put them for
Readability,
like

“You know that cut I could have made it, but I wanted to make a three
put on
the last green for more readability ;)”

R.


Deux choses sont infinies : l’univers et la bêtise humaine ; en ce qui
concerne l’univers, je n’en ai pas acquis la certitude absolue.

  • Albert Einstein

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