ratulb
April 25, 2025, 9:15pm
1
I have two functions - each taking a VariadicList
. If I want to pass the received VariadicList
as it is to another - it does not work. How to make it work? I am pasting the compiler output below:
fn take(*take_input: Int):
pass
fn give(*give_input: Int):
take(give_input)
fn main():
print("hello")
error: invalid call to ‘take’: argument #0 cannot be converted from ‘VariadicList[Int]’ to ‘Int’
take(give_input)
^ ~~~~~~~
Helehex
(Max Brylski)
April 25, 2025, 9:30pm
2
What you’re looking for is variadic unpacking, which is currently unsupported:
fn give(*give_input: Int):
take(*give_input) # unpacked arguments are not supported yet
A potential work-around is to use VariadicList
directly, and create a wrapper which has variadic arguments:
fn take(take_input: VariadicList[Int]):
pass
fn take(*take_input: Int):
take(take_input)
fn give(*give_input: Int):
take(give_input)
fn main():
print("hello")
ratulb
April 25, 2025, 9:36pm
3
That woks. Thanks for the prompt reply - much appreciate it.
system
(system)
Closed
May 2, 2025, 9:37pm
4
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.