-
-
Notifications
You must be signed in to change notification settings - Fork 75
Open
Description
I was reading the Gleam language overview on list patterns and it's not clear that you can store the matched values in variables. While this is seen 3 sections below on the list recursion section, its main point is not to show how list patterns function, so I think it would be nice to have it in the documentation. Something like:
You can also store these values in variables.
[first, second, ..rest]will match the first two values infirstandsecondrespectively and the rest inrest
And in the examples:
import gleam/string
import gleam/int
import gleam/list
[3] -> "List of just 3"
[3, ..rest] -> "List starting with 3 and the rest being: " <> rest |> list.map(fn(n) { int.to_string(n) }) |> string.join(", ")Metadata
Metadata
Assignees
Labels
No labels