P
Philliam Auriemma
Hey all,
I'm pretty new to ruby, and I absolutely love it. I have aquestion. I
have programmed in a language called lua before (which had real full-
fledged anonymous functions), and with a lua table, which is Lias
version of a hash and an arrary combined, you could do something like
this:
newtable = { 1 = function() print("hi from 1") end,
2 = function() print("hi from 2") end
}
even though some of you haven't even ever heard of lua before, it's
easy to guess what this does: it creates two keys, 1 and 2, in a
table, newtable, and assigns two functions as their values. After
doing that, you can do this:
newtable[1]()
To call the function stored in newtable[1]. All that begs the
question: is something similar available in ruby?
I'm pretty new to ruby, and I absolutely love it. I have aquestion. I
have programmed in a language called lua before (which had real full-
fledged anonymous functions), and with a lua table, which is Lias
version of a hash and an arrary combined, you could do something like
this:
newtable = { 1 = function() print("hi from 1") end,
2 = function() print("hi from 2") end
}
even though some of you haven't even ever heard of lua before, it's
easy to guess what this does: it creates two keys, 1 and 2, in a
table, newtable, and assigns two functions as their values. After
doing that, you can do this:
newtable[1]()
To call the function stored in newtable[1]. All that begs the
question: is something similar available in ruby?