2

On Mathematica 12.2 the code

x = <||>;
AssociateTo[x, "foo" -> {{1, 2}, {3, 4}}]
x["foo"][[1]] += {0, 1}

raises the error

Set::setps: x[foo] in the part assignment is not a symbol.

whereas

x["foo"][[1]]

returns {1,2} just fine.

Should the increment work?

user90346
  • 355
  • 1
  • 4

1 Answers1

0

You could access the subparts of the association via x["foo"][[1]], but you could also access it as x[["foo", 1]]. Knowing that, your increment statement should be written

In[73]:= x[["foo", 1]] += {0, 1}

Out[73]= {1, 3}

Jason B.
  • 68,381
  • 3
  • 139
  • 286