Implement Sigil in Elixir
Sigil’s in Elixir is an extremely powerful construct which contributes greatly to developer productivity.
Some of the well know sigils are
But have you ever wondered how you can implement your own sigil?
Recently, José Valim held a live stream on Twitch where he solved Day 4 of Advent of Code. At the end of his stream (in the section he called it his “ramblings”) he explained how sigils can be implemented.
This article is so that I get to practice his teachings by applying them on a chess game I’ve been working on.
Context
Let’s imagine that we have the following struct to represent a chess board with all it’s pieces
As can be seen in the setup functions, it would be difficult to initialize a chess board using all of it’s pieces.