baronfel / fsharp-lang-testbed

0 stars 0 forks source link

Introduce array spread operator for pattern matching and [<ParamArray>] #28

Open baronfel opened 7 years ago

baronfel commented 7 years ago

Idea 11462964: Introduce array spread operator for pattern matching and []

Status : declined

Submitted by Ryan Riley on 1/15/2016 12:00:00 AM

18 votes

Several languages have introduced a handy spread operator, ..., that can be used to pick up remaining arguments to a function call or when destructuring values. [1] This would be incredibly helpful in F# to reduce boilerplate in methods accepting a [] or when trying to pattern match arrays: match [|1;2;3;4|] with | [||] -> // do stuff with empty array | [|hd;…tl|] -> // do stuff with hd/tl [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator