Filter = Returns(false)

This is used as a default keyword argument in some function. What does it mean?

What does ‘Returns()’ mean? Is it a function?

Returns(false) is a 0 argument function that returns the value false. It’s basically the anonymous function () -> false

1 Like

Yes, it’s a function call, you can tell from the parenthesis. The capital R signals that it’s a constructor - though this is just convention and not enforced.

Specifically, I think a Returns is a functor that always returns the same value when called as a function. Try ?Returns in a REPL session.

1 Like

That’s actually a function which takes any number of positional and keyword arguments, not a 0-arg function.

julia> Returns(false)(1, missing, "hello"; a="world", b=3.14)
false
3 Likes