Method declaration and passing parameters to call other methods?

Viewed 13

I have a method (Named : set_generation1) in ruby which calls an other method (Named :foo4) from the body of it. All the Method set_generation1's parameters are already passed to Method foo4 as arguments and everything is fine. Problem Statement - Now I want to introduce a similar method like set_generation1 (named : set_generation2) which should also call the method foo4 from its body using its own parameters. However, I'm getting an error message in method : set_generation2 to include the parameters of set_generation1. I want the method foo4 to take customizable arguments when necessary.

def set_generation1 class_prod, class_corp, run_user, application: @application

    all_class_prod = Rails.configuration.input1[:prod] + class_prod.split(",").map(&:strip)
    all_class_corp = Rails.configuration.input1[:corp] + class_corp.split(",").map(&:strip)

    foo4 material_set_name_prod, all_class_prod, run_user, application
   
    foo4 material_set_name_corp, all_class_corp, run_user, application
  end
def foo4 all_class_prod, all_class_corp, run_user, application

.......

end 

*** NEW ***

def set_generation2 account_id, application: @application

    all_account_id = Rails.configuration.input2[:prod] +account_id.split(",").map(&:strip)

    foo4 material_set_name_prod, all_account_id, application ***(GETTING ERROR HERE TO INCLUDE set_generation1's parameters)*** 
   
    end
0 Answers
Related