Ok, so here is example code:
Clear[p, flag, k]; p = 2; k = 1; flag = True; If[flag, p, k] = 0; p
After that I get the message
Set::write: Tag If in If[True,p,k] is Protected.
And p is still 2 instead of 0. How can I make the p equal to 0 in this case?
EDIT: My question is general - how to return the symbol from some function, not only If - and be able to change its value later (for example by Set)
EDIT #2: I know that with associations I can do that easily:
Clear[p, flag, k]; v = <||>; v[p] = 2; v[k] = 1; flag = True; v[If[flag, p, k]] = 0; v[p]
I just wish I could the same just on symbols..