Re: [elixir-talk:13107] bind a pattern matching in a function declaration

29 views
Skip to first unread message

Rickard Andersson

unread,
May 16, 2016, 5:37:35 AM5/16/16
to elixir-l...@googlegroups.com
Yes, as follows:

def my_function([head | tail] = list) do
# use whichever part you want
end

// gonz

On Mon, May 16, 2016 at 02:25:24AM -0700, hdcos wrote:
> Hello there :),
>
> is it possible to do something like this:
>
> def my_function([hd | tail] as my_list) do
> #use my_list hd and tail
> end
>
>
> --
> You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/6cdde1fa-29e8-45c6-8566-00636061558f%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages