def foo(*args)
h = (Hash === args.last ? args.pop : {})
args.each{|m| h[m]=m}
args = h
#....
end
T.
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
#....
endT.
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.
On 10/10/06, Trans <transfire@gmail.com> wrote:
Trans wrote:
> def foo(*args)
> h = (Hash === args.last ? args.pop : {})
> args.each{|m| h[m]=m}
> args = h
> #....
> end
>
> T.GOLF.
T.
--
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