PassiveSupport.Atom (passive_support v0.8.4)
Functions for working with atoms and strings which may reference atoms
Link to this section Summary
Functions
Returns true if the passed-in value resembles an existing atom and false if it does not.
If able, casts the string to an existing atom, returning nil
if not.
Link to this section Functions
Link to this function
exists?(atom)
Specs
Returns true if the passed-in value resembles an existing atom and false if it does not.
Examples
iex> exists?(:foo)
true
iex> exists?("yes")
true
iex> exists?("bar")
false
iex> exists?("false")
true
iex> exists?("nil")
true
Link to this function
from_string(atomish)
Specs
If able, casts the string to an existing atom, returning nil
if not.
Also passes atoms through, for convenience.
Examples
iex> from_string("ok")
:ok
iex> from_string("error")
:error
iex> from_string("true")
true
iex> from_string("false")
false
iex> from_string("nil") # `nil` is, itself, an atom
nil
iex> from_string("what's all this then?")
nil
iex> from_string(:foo)
:foo