What is wrong with this code? I was expecting "titi"in person.name, but I still have one "toto"! More specifically, how to change an entry in a function?
"titi"
person.name
"toto"
init1()-> S=#person{name="toto"}, %record creation and field setting fct(S), io:format("~s~n",[S#person.name]). fct(R)-> R#person{name="titi"}. %record updating
fct():
init1()-> S=#person{name="toto"}, %record creation and field setting S2 = fct(S), % Get updated record io:format("~s~n",[S2#person.name]). fct(R)-> R#person{name="titi"}. %record updating
, . , - , , @hdima. , . Erlang, . ETS, , .
, ETS, dataโโstrong > , /. , / :
Without writing new data to the dictionary / table, it will be lost, since your new data was.
Inside fct (), you are not mutating the entry, but you are returning a new value for the entry, which must be used later. If you call fct (S) without referring to the return value, you will lose this new value ("titi").
Source: https://habr.com/ru/post/1784556/More articles:Free CMS? (Or CMF) - phphttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1784552/daily-unique-visitors-reporting-in-google-analytics&usg=ALkJrhi_OjxjrBzPZToTElsq1Y2_w34hegtabbedpanel - stay on the current tab, but change the contents of the tab - javarelative link for the directory above - htmlHTML / JavaScript debugging in Eclipse - javascriptString.Empty or null: which is better to return for the Error field from the service? - stringJoin Unions - sqlstd :: set > :: find (), without building a string copy - c ++JEditorPane HTML rendering - javaGetting a 32-bit COM client for working with a 64-bit server outside the processor using Java / JaCoB - javaAll Articles