You Should Blog

I created this blog to reflect on my code and development as a programmer. In that spirit, I’d like to make a pitch to anybody reading: you should blog. Why? For me, it’s been an invaluable opportunity to practice explaining my thoughts, and to watch myself grow. Explaining Thoughts Translating technical ideas into words is one of the great challenges of being a programmer. We have to master it. Communicating well with everyone on your team is crucial. ...

February 11, 2017

Writing Elixir Sigils

Sigils are a mechanism for working with textual representations in Elixir. If you’ve ever made an array of Strings in Ruby with %w(), the API is similar. A neat feature of sigils is that we can make custom variants, or override existing Kernel variants. The latter is generally discouraged. Creating a Sigil Here’s some code I wrote for an exercise, defining a new sigil, u: defmodule SigilWriter do @moduledoc """ Provides a module for creating new sigils. """ @doc """ Defines the new sigil function for `u`. """ def sigil_u(content, _opts) do content |> String.split |> Enum.map(&String.downcase/1) end @doc """ Calls the `u` sigil. """ def split_and_downcase(content) do ~u(#{content}) end end The sigil_u function defines the new u sigil— u is just a convenience method. This function takes the content, splits it, and downcases each word in the list. This only works because u is not already a defined sigil in Elixir. ...

July 4, 2016