
Elixir Weekly Tips #1 (Tips 1-5)
5 byte-sized tips for Elixir
#1. IEx Helpers in Livebook
#Elixir Tip of the Day #1: IEx Helpers can help ease the transition from Jupyter to @livebookdev and you might not even be aware of them. Pair them with Smart Cells and you can get very similar functionality to Jupyter Magics#MyElixirStatus pic.twitter.com/F7ApHH2LR0
— Andrés C Alejos (@ac_alejos) July 18, 2023
#2. mix_recompile
?/0
Function
Elixir Tip of the Day #2: Use `__mix_recompile__?/0` to control when a module will be recompiled by Mix beyond its normal dependency tracking.
— Andrés C Alejos (@ac_alejos) July 19, 2023
Here is an example from the docs which shows tracking when the contents of a directory changes. #MyElixirStatus pic.twitter.com/GjwcRGhRmM
#3. match?/2
Macro
Elixir Tip of the Day #3: You can use the `match?/2` macro to perform guarded matches. This can be a more concise way to perform filtering during enumerations. Combine with `defguard/1` macro to create complex and powerful matches.https://t.co/Wgc4w1i11L#MyElixirStatus pic.twitter.com/EIKjGpTZEg
— Andrés C Alejos (@ac_alejos) July 19, 2023
#4. The __binding__/1
Macro
Elixir Tip of the Day #4: The `binding/1` macro returns all bound variables from the given context as a keyword list. This is especially useful when combined with the bind_quoted option of quote to bind all variables within the quoted block.#MyElixirStatus pic.twitter.com/l9ngw7PSwX
— Andrés C Alejos (@ac_alejos) July 21, 2023
#5. The __deriving__/3
Macro
Elixir Tip of the Day #5: Within an Any implementation of a protocol, define the `__deriving__/3` macro to accept options. This allows configurable fallback behaviors rather than just one implementation. Modules like Jason and Inspect use this in great ways#MyElixirStatus pic.twitter.com/0pxKsF858j
— Andrés C Alejos (@ac_alejos) July 20, 2023