loading...

re: My First Week With Elixir As A Rubyist VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Great writeup! I've also started learning Elixir not long ago and have been loving every minute of it. Just a slight suggestion, you can add guard...
 

You can also match on equality by re-using the same param name in the function definition:

defmodule Example do
  def any?([], _a), do: false
  def any?([a | _tail], a), do: true
  def any?([_head | tail], a), do: any?(tail, a)
end
 

I really dig the pattern for head being equal to the element you are looking for.

code of conduct - report abuse