Besides the ability to apply function (like stringify `$`) to the parameters,
varargs is nothing but an openArray with an alternative way of specifying
arguments available. The normal way is still useful for e.g. when you forward
parameters or when you don't know how many parameters you have and you pas over
a seq:
import strutils
proc printStuff(x: varargs[string]) =
for element in x:
echo element
let lines = readFile("file.txt").splitLines()
# the same proc used in two occaisons
# afaik in C++ you would have to write a wrapper for printStuff
printStuff "Hi, how are you going?", "Here's the content of a file"
printStuff lines
Run
- Why does the this code work? sigmapie8
- Re: Why does the this code work? dawkot
- Re: Why does the this code work? sigmapie8
- Re: Why does the this code work? Stefan_Salewski
- Re: Why does the this code work? dawkot
- Re: Why does the this code work? doofenstein
- Re: Why does the this code work? cumulonimbus
- Re: Why does the this code w... lscrd
- Re: Why does the this code w... cumulonimbus
- Re: Why does the this code w... lscrd
- Re: Why does the this code w... mratsim
- Re: Why does the this code w... cumulonimbus
- Re: Why does the this code w... Araq
- Re: Why does the this code w... lscrd
