Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Pattern matching is fantastic. Also, there are guards:

  def handle_info(msg, state) when is_tuple(msg) do
    # ...
  end
I haven't written anything big with Elixir/Erlang yet, but I definitely feel more confident my Elixir code will work than Python, say. Not as much as Go, though.

As an aside, comparing:

  {:ok, port} = Port.open(...)
to something similar in Go:

  port, err := port.open(...)
  if err != nil {
    panic(err)
  }
That's very convenient. Also, you can bind multiple times to a single argument (sort of like what you showed):

  def handle_info([], state = {ppid, _port}) do
    Supervisor.stop(ppid)
    {:noreply, state}
  end
That's not a default argument, that's binding the second argument to state and the pid inside the state tuple.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: