The following does compile though I wouldn't recommend actually using it, it
looks like a bunch of red-flags. Maybe explicitly converting every value to a
string is better, or if you really want to making a macro also works.
type
QueryParam* = tuple[key: string, value: string]
proc bar*(x: (string, auto)): QueryParam =
(x[0], $x[1])
proc foo*(x: varargs[QueryParam, bar]) =
for (key, value) in x:
assert value is string
# foo({"a": "1", "b": 2}) # This doesn't work
foo(("a", "1"), ("b", 2))
Run
- Some sort of interface-like functionality or varargs mishankov
- Some sort of interface-like functionality or varargs c4UlMu
- Some sort of interface-like functionality or vararg... Patitotective
