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

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

@spec 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

Example

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