Elixir Language Sigils Custom sigils

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Custom sigils can be made by creating a method sigil_X where X is the letter you want to use (this can only be a single letter).

defmodule Sigils do
  def sigil_j(string, options) do
    # Split on the letter p, or do something more useful
    String.split string, "p"
  end
  # Use this sigil in this module, or import it to use it elsewhere
end

The options argument is a binary of the arguments given at the end of the sigil, for example:

~j/foople/abc # string is "foople", options are 'abc'
# ["foo", "le"]


Got any Elixir Language Question?