Array to arguments for a method?
#1
I feel like I've asked this before, and I'm sure I managed to make this work at least once. I don't think I remember how. Anyway, I'm trying to figure out how to turn an array into a set of arguments for a method.

Quick example I'm putting out there, just because it's something I'm trying to figure out: Turning this array
Code:
@sound = ["Audio/SE/002-System02", 80, 100]

into a set of arguments for
Code:
Audio.se_play(filename[, volume[, pitch]])
Reply }
#2
Well you can do:
Code:
Audio.se_player(@sound[0], @sound[1], @sound[2])

If you want it automated you can use the eval(string) function which is used to execute a string as code.
Valdred
Tech Administrator of Save-Point
Reply }
#3
Val! Thanks, but I figured it out, sorry to say. I forgot about how useful *array can be.

Code:
somearray = [0, 1, 2]
method(*somearray)

Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   New Encryption Method Test Legacy 2 4,750 05-22-2010, 07:17 PM
Last Post: Monster Buffer
   how to check if a method has been aliased? Charlie Fleed 6 9,192 01-21-2010, 06:26 PM
Last Post: DerVVulfman



Users browsing this thread: 1 Guest(s)