Discussion on Naming Conventions for Elixir List Pattern

143
clicks
Discussion on Naming Conventions for Elixir List Pattern

Source: reddit.com

Type: Discussion

A user, DerGsicht, expressed a preference for using a particular pattern to match nonempty lists in Elixir. They refer to a pattern, denoted by [_ | _], used to match a list with at least one element. Instead of the guard combination, the author finds this pattern more succinct and is curious if there's a descriptive, potentially official, name for it akin to the walrus operator ':=' in Python. A commenter, lpil, suggests simply referring to the pattern as 'any list of at least one element' and cautions against the use of joke names which might confuse others or require further explanation.

© HashMerge 2024