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]?
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]?