Last active
April 24, 2017 12:36
-
-
Save shahryarjb/3672246ed237ee9c841d234095c7fe46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# my blog : https://trangell.com/fa/ | |
# public : http://iranonrails.ir | |
defmodule Customer do | |
defstruct name: "", company: "" | |
end | |
defmodule BugReport do | |
defstruct owner: %Customer{}, details: "", severity: 1 | |
end | |
defmodule User do | |
report = %BugReport{owner: %Customer{name: "Dave", company: "Pragmatic"}, details: "broken"} | |
IO.inspect report | |
report = %BugReport{ report | owner: %Customer{ report.owner | company: "PragProg" }} | |
IO.inspect report | |
IO.inspect update_in(report.owner.name, &("Mr. " <> &1)) | |
end | |
# | |
report.owner.company | |
put_in(report.owner.company, "joom shoper") | |
update_in(report.owner.name, &("MR. " <> &1)) | |
put_in(report[:owner][:company], "PragProg") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
report.owner.company
put_in(report.owner.company, "joom shoper")