Variadic function parameters

How to dynamically provide a variable number of string prms to a variadic function.

Say I have a variadic function that accepts a variable number of strings. How can I call this function with dynamically generated parameters, say from a config file: stringA, stringB, stringC etc.

Can I ‘unwind’ a slice of strings?

Thanks in advance.

Given a function func f(s ...string) you can call it f(s1, s2, s3) etc.

If you have a slice of strings you can call it f(slice...), though you can not mix both calling conventions.


Thanks Norbert. The slice… method does it for me as I’m just reading strings from a config file.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.