# How do I localize an assignment to expression (instead of symbol) within scoping construct?

Is it possible to localize an assignment to an expression (defined via UpSet) instead of a Symbol within a scoping construct?

It would be nice if I had something like the following at my disposal:

Block[{f[1,2]=ab}, (*<-- what I need*)
Table[f[i,j],{i,1,2},{j,1,2}]
]


(I need to use Block. Module and With are not correct for my case.)

If you need to preserve the definitions of a Symbol with exception(s) to some particular case(s) you should use InternalInheritedBlock:

f[a_, b_] := a + b;

InternalInheritedBlock[{f}, f[1, 2] := ab;
Table[f[i, j], {i, 1, 2}, {j, 1, 2}]]

f[1, 2]

{{2, ab}, {3, 4}}

3

• This is even better than my answer! Thanks Nov 2, 2014 at 14:19
• Jan 16, 2015 at 22:29