Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# my blog : https://trangell.com/fa/
# public : http://iranonrails.ir
defmodule Subscriber do
defstruct name: "", paid: false, over_18: true
end
iex(1)> s1 = %Subscriber{name: "shahryar" }
%Subscriber{name: "shahryar", over_18: true, paid: false}
iex(2)> s2 = %Subscriber{name: "ruby" , over_18: false }
%Subscriber{name: "ruby", over_18: false, paid: false}
iex(3)> %Subscriber{name: a_name } = s2
%Subscriber{name: "ruby", over_18: false, paid: false}
iex(4)> a_name
"ruby"
iex(5)> s4 = %Subscriber{s2 | name: "mojtaba"}
%Subscriber{name: "mojtaba", over_18: false, paid: false}
iex(6)> s4.name
"mojtaba"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment