Skip to content

infinitered/maybe

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Maybe

Hex.pm Build Status

Access nested Elixir maps and structs, protected from nil. Somewhat similar to "Optionals" in Apple Swift.

import Maybe

info = %{city: %{name: "Portland"}}
maybe(info.city.name)
# => "Portland"

map = %{}
maybe(map.city.name)
# => nil

See the original forum post for more an explanation of the problem this package solves.

Installation

Add maybe to your list of dependencies in mix.exs:

def deps do
  [
    {:maybe, "~> 1.0.0"}
  ]
end

See the documentation for more details.

About

Access Elixir maps and structs, protected from `nil`

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published