Easily ignore labeled arguments?

With normal arguments you can do this:

let foo = (_bar) => false

to get rid of warning 27: unused variable

Is there a way to do something as easy with labeled arguments.
I’m aware you can say

let foo = (~bar) => {
  bar->ignore
  false
}

But imho that’s not “good enough” because often it means I need to add curly brackets to a function that had none before.

I’ve actually considered changing some of the functions to use a single record as an argument instead of a set of labeled arguments to make this easier to manage. What do people think about that approach?

2 Likes

What’s the use case?
you usually want to consume the argument.

I think you can use as to rename the argument:

let foo = (~bar as _) =>  false
4 Likes

Nice. I didn’t know you can do that. That’s good enough for now :slight_smile:

Edit: The use case is reusable components that offer a callback function prop that has multiple arguments. Sometimes you use them, sometimes you don’t.

2 Likes