Contentful.Misc (Contentful SDK v0.4.1) View Source

Provides some functions that fit nowhere else and can be shared freely.

Link to this section Summary

Functions

provides a generic fallback method in case a returned value is nil.

Link to this section Functions

Specs

fallback(nil, any()) :: any()

provides a generic fallback method in case a returned value is nil.

Inspired by @expede and her talk at Code BEAM V 2020.

Usable in conjunction with other getters to enable function chains:

Example

1 = [a: 1, b: 2, c: 3] |> Keyword.get(:a)
4 = [a: 1, b: 2, c: 3] |> Keyword.get(:d) |> fallback(4)