Why can’t I chain String.replace?

EDIT On the master branch of Elixir, the compiler will warn if a function is piped into without parentheses if there are arguments. This is an issue of precedence that can be fixed with explicit brackets: price |> to_string |> String.replace(“.”, “,”) |> String.replace(~r/,(\d)$/, “,\\1 0″) |> String.replace(” “, “”) Because function calls have a … Read more

What does the slash notation in Elixir mean?

From page 2, Basic types of the Getting started documentation: Note: Functions in Elixir are identified by name and by number of arguments (i.e. arity). Therefore, is_boolean/1 identifies a function named is_boolean that takes 1 argument. is_boolean/2 identifies a different (nonexistent) function with the same name but different arity. It is also described in Erlang/Elixir … Read more

Multiline comment in Elixir

Elixir does not have multiline comments. However, one very common use case for multiline comments is documenting modules and functions, for which you can use the module attributes @doc and @moduledoc together with heredocs. defmodule MyModule do @moduledoc “”” This module is great at X “”” @doc “”” Frobnicates the given string. “”” def frobnicate(s) … Read more

Is there an identity function in Elixir?

@focused is correct – 1.10-dev has added the identity function. Documentation Old Answer: No such function has been predefined (at least that I’m aware of). It can trivially be written as you’ve done in your question, or more succinctly as &(&1).