4 ms·
This is surprising to me: l[1][1].age:9 # (1,(2,{"age":9}),4) How come it doesn't return just: {"age":9} Or is there something totally different going
by leontrolski 5mo ago
This is surprising to me:
l[1][1].age:9
# (1,(2,{"age":9}),4)
How come it doesn't return just:
{"age":9}
Or is there something totally different going on with references here? As in, how is this different to:
l_inner = l[1][1]
l_inner.age:9
- RodgerTheGreat 5mo agoAmending a slice would amend only the slice: l_inner:l[1][1] # {"age":3} l_inner.age:9 # {"age":9} l_inner # {"age":9} l # (1,(2,{"age":3}),4) If an amending expression isn't "rooted" in a variable binding, it also returns the entire new structure: (1,(list 2,list ().age:5),4)[1][1].age:99 # (1,(2,{"age":99}),4)