Skip to content

Commit

Permalink
Adding a nested DS example.
Browse files Browse the repository at this point in the history
  • Loading branch information
algogrit committed Mar 20, 2024
1 parent e849bd1 commit 7512a94
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions examples/03-ds/nested_ds_companies.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
m = %{}

# cm_emp = m["CoderMana"]
# cm_emp = (cm_emp || []) ++ ["G A"]
# Map.put m, "CoderMana", cm_emp

# (or)

m = update_in m, ["CoderMana"], fn (cm_emp) -> (cm_emp || []) ++ ["G A"] end
# update_in m, ["CoderMana"], fn (cm_emp) -> ["G A" | (cm_emp || [])] end

# ---

m = %{
"Toshiba" => ["Bhautik", "Saraswati", "Nagaraj"],
"CoderMana" => ["Gaurav"],
}

m = update_in m, ["CoderMana"], fn (cm_emp) -> (cm_emp ++ ["G A"]) end

0 comments on commit 7512a94

Please sign in to comment.