In C++11 we have Variadic functions that we can call with varying number of arguments. https://stackoverflow.com/a/1657930/2402577

void myfunc( int i = 0, int j = 1, int k = 2 );

// other code...

myfunc( 2 );
myfunc( 2, 1 );
myfunc( 2, 1, 0 );

I have point out that it is not possible, instead could we just sent an array list into the function, and embedded arguments into the list:

function foo(uint hello[]){
     uint x = hello[hello.len];
     return x + 1;

[Q] Is it possible to make something similar inside Solidity with an array-list[] as an argument to the function?


No this is not possible for now. The same question was asked here :

Variadic Functions in Solidity

  • 3
    Hi there. If you think a question has already been asked before, then flag it as a duplicate. That way it prevents other people potentially wasting their time creating and writing duplicated answers. (To flag: Close -> Duplicate of -> <paste the URL of previous question>) – Richard Horrocks May 5 '17 at 13:21
  • I am sorry my bad. Should I assume is it possible to send a list array[] to the function than? since we can return from a function call as array[]? I have combined my question with that. The duplicate Q was asked on 2016 so I wanted to double check for an update. @RichardHorrocks – alper May 5 '17 at 13:38
  • Oh sorry, I would have done it but I thought I didn't have the required permissions to mark is a duplicate. – Antokop May 5 '17 at 14:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.