ValuePreprocessingFunction

ValuePreprocessingFunction

is an option for functions such as PersistentValue and InitializationValue that specifies a function to apply to a new value that is being assigned.

Details

Examples

Basic Examples  (1)

Define a value preprocessing function for a particular persistent value that accepts only integers:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input

Assign an integer at any persistence location:

In[3]:=
Click for copyable input

Assigning anything else generates an error, and the assignment is not performed:

In[4]:=
Click for copyable input
In[5]:=
Click for copyable input
Out[5]=

See Also

PersistentValue  PersistenceLocation  Protected

Introduced in 2017
(11.2)