Ruby Array args to function
in lua you can do somthing like
so the function can take any number of args,
How do you do this in ruby?
I cant seem to find out anywhere..
Code:
function printEveryArg(...)
for _, item in pairs( arg ) do
io.write(item.."\n")
end
end
so the function can take any number of args,
How do you do this in ruby?
I cant seem to find out anywhere..
Sir, e^iπ + 1 = 0, hence God exists; reply!
Code:
def printEveryArg(*args)
puts args.join("\n")
end
(args is a standard ruby array)
Thanks Keith.
Im making a 2D Rigid Body physics engine with the RubyGameShell to try and learn ruby better..
So im on my way..
Im making a 2D Rigid Body physics engine with the RubyGameShell to try and learn ruby better..
So im on my way..

Sir, e^iπ + 1 = 0, hence God exists; reply!
Possibly Related Threads...
Thread: | Author | Replies: | Views: | Last Post | |
Ruby on Rails setting Time to NULL | BeyondCloister | 3 | 5,589 |
Nov 21, 2007 09:56 AM Last Post: AndyKorth |
|
Ruby, MacPorts, Firewalls | BeyondCloister | 3 | 5,886 |
Nov 6, 2007 04:57 PM Last Post: OneSadCookie |
|
Ruby: Resources for Learning | iefan | 10 | 9,879 |
Jul 4, 2007 08:54 AM Last Post: ALX99066 |
|
Ruby Gems and OpenGL | Jaden | 2 | 4,204 |
Apr 2, 2007 01:15 AM Last Post: Jaden |
|
Embedding Ruby | DesertPenguin | 3 | 4,782 |
Jan 5, 2007 09:11 PM Last Post: DesertPenguin |