Not related to practical usage, just for conceptual understanding as a newcomer: in julia, named tuples is one of the types that are immutable:
t = (a = rand(2,2), b = rand(3,3)) t.a = rand(2,2) #ERROR: setfield! immutable struct of type NamedTuple cannot be changed
however, broadcasting assignment works:
t.a .= rand(2,2) changes
t.a. I remembered reading from somewhere (cannot find reference now…) that it’s more helpful to think that the “value” of array in julia is not the actual content, but memory address, and in this example, while named tuple are immutable so that its values cannot be changed afterwards, we are not really changing the value with
t.a .= rand(2,2) since the “value” is memory address, which is not changed: e.g. confirmed
pointer(t.a) is not changed with the broadcast assignment. Also, with a regular array
a=rand(3,3), a new assignment
a=rand(3,3) changes both the content and pointer, while
a .= rand(3,3) changes just the value but not the pointer.
Is it a correct understanding? Thanks!