*args and methods that take specific params

we all know that you can do:

def method_a(*args) #blaendthis allows you to pass in, in my case an array or what ever i want. it saves me from creating methods like: def method_a (id, item, item_type ....)

How ever, what it doesn't allow me to do, unless I am doing it wrong, hence why I am asking here, is:

def method_a(*args) Sample.new(specific_param, specific_param, specific_param, ...)endWhat I tried doing was: Sample.new(*args.join(',')) but it spazzes out saying it wants x arguments where as I gave it one. am I missing something when it comes to handling a situation like this? if the answer is to say, well make Sample take in *args as it's argument, then how would you get the specific parts out of *args to satisfy this:

class Sample attr_reader :some_argument attr_reader :argument_a def initialize(some_argument, argument_a) @some_argument = some_argument @argument_a = argument_a endendCan I treat *args as an array and go: *args[0], *args[1]?
You should be able to just say args[0] and args[1]
I figured as much, because *args is really just an array. thanks. /thread
You can also use args.size to determine how many parameters were passed, in case you need to fill anything in with defaults (or ensure you're not trying to pass through a parameter to the next function that wasn't actually received).


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/args-and-methods-that-take-specific-params.15336/