P
Paatsch, Bernd
------_=_NextPart_001_01C6310C.FA33C48B
Content-Type: text/plain
I like to write a generic method that calls different functions depending on
what string I parse to the method (see example) without having to use a
case-when? Is there a way to do that?
Process_easy("aFile", "Summer")
def process_easy(file, what)
if file.include?("#{what}#{NL}") then
constructor = CategoriesFactory.start_what # this is wrong. I like to
substitute and have: constructor = CategoriesFactory.start_summer
start = file.index("Summer#{NL}")
return constructor
# etc
end
-Bernd
------_=_NextPart_001_01C6310C.FA33C48B--
Content-Type: text/plain
I like to write a generic method that calls different functions depending on
what string I parse to the method (see example) without having to use a
case-when? Is there a way to do that?
Process_easy("aFile", "Summer")
def process_easy(file, what)
if file.include?("#{what}#{NL}") then
constructor = CategoriesFactory.start_what # this is wrong. I like to
substitute and have: constructor = CategoriesFactory.start_summer
start = file.index("Summer#{NL}")
return constructor
# etc
end
-Bernd
------_=_NextPart_001_01C6310C.FA33C48B--