# Why it is doing part assignment? [closed]

I am writing an algorithm and need to keep updating an association called "verticesAssoc". My algorithm ran perfectly at first. However now I want to use the same algorithm on another association "verticesAssocPart[i, j]", where the index will be given. I changed all "verticesAssoc" into "verticesAssocPart[i, j]", so I think literally there should be no problem, it is just like changing the name of a variable. However the bugs kept coming up saying "xxx in the part assignment is not a symbol". Why it worked before with "verticesAssoc" but now it fails with "verticesAssocPart[i, j]"? There shouldn't be any problem because no matter it's the "verticesAssoc" or "verticesAssocPart[i, j]", they are not passed as parameters into a module since my module is simply doing operations on them.

I checked the stack trace and as you can see at the If part I am doing a MemberQ check, and then it says I am doing an illegal part assignment. I can't see where the problem is, can someone help me?

My association stores information in the form <|pt_1 -> {{pt_2, "s"}, {pt_3, "d"}}|>, where "pt"s are 5D coordinates and "s/d" is simply a string.

## closed as off-topic by Henrik Schumacher, Kuba♦Jan 2 at 11:50

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Henrik Schumacher, Kuba
If this question can be reworded to fit the rules in the help center, please edit the question.

• Please, get used to post copyable code so that we can try it out easily. Nobody wants to retype everything or parse your code in gedanken Mathematica. – Henrik Schumacher Dec 2 '18 at 16:37
• Sorry about that. I thought it won't help much to put codes here since my algorithm is too long, but the idea is that I have an association, and I am updating it by a module (I am pretty sure I don't pass the association as a parameter into the module). It works perfectly well. Then I want to use that module to update an association with another name. I substitute all old names in the module and then it doesn't work. – Apocalypse Dec 2 '18 at 17:05
• Really, this cannot be answered without looking at the actual code that you use. Please provide a minimal example. – Henrik Schumacher Dec 2 '18 at 17:08

The problem is that, as the error says, verticesAssocPart[i,j] is not a symbol. Essentially what happens is that verticesAssocPart[i,j][…]=… becomes <|…|>[…]=… in a first step, which is clearly meaningless (Unlike in most programming languages, nearly everything in Mathematica is immutable - so verticesAssocPart[i,j] is not a reference to some mutable association, but an immutable copy of that association).
What should work in your case is verticesAssocPart[[i,j,Key[…]]=…, since now there's nothing to prematurely evaluate, only a single (nested) part assignment. Without seeing your code, more specific help will be impossible.