Call function without Keywordarguments with an empty NamedTuple

Since it is possible to call functions with NamedTuples, I was wondering if there is a way to call a function that has no keywordarguments with an empty NamedTuple, and if not, why is it not desirable?


function f()

Yes, you can!

test() = println("Hi") # no args no kwargs
kwargs = NamedTuple()
args = tuple()
# Hi

The difference with your code example is that I used ... which unpack the arguments. f(NamedTuple()) is reserved to mean a function with one argument that is a empty NamedTuple.

1 Like

Oh, I totally forgot that! I was usually using the ... in the function itself but did forget that they could be used also in the function call!
Thank you!