small medium large xlarge

21761646_10203847227898145_7438348763502414745_n_pragsmall
21 Nov 2017, 16:14
Marco Carvalho (9 posts)

In Chapter 8, section, “Nested Dictionary Structures”, I decided to try:

iex(10)> put_in(report.owner.name, "Dave Thomas") 

which returns:

%BugReport{details: "broken",
 owner: %Customer{company: "PragProg", name: "Dave Thomas"}, severity: 1}

So far so good. However, when I ran:

iex(11)> update_in(report.owner.name, &("Mr. " <> &1))

The following was returned:

%BugReport{details: "broken",
 owner: %Customer{company: "PragProg", name: "Mr. Dave"}, severity: 1}

What happened to, “Thomas” ?

21761646_10203847227898145_7438348763502414745_n_pragsmall
21 Nov 2017, 16:39
Marco Carvalho (9 posts)

Figured out that its because the data is immutable. What I should have done was something like:

report = put_in(...)
You must be logged in to comment