WOLFRAM

represents the settable persistent value with which the symbol sym will be initialized.

InitializationValue["context`name"]

represents the settable initialization value for the symbol with the specified complete name.

InitializationValue[sym,{loc1,}]

specifies the persistence locations to search for a possible initialization value.

Details and Options

Examples

open allclose all

Basic Examples  (2)Summary of the most common use cases

Set a value to be evaluated every time the kernel starts:

Out[1]=1

Set an initialization value for a variable:

Out[1]=1

Get any initialization value defined:

Out[2]=2

Initialize the variable from the persistent value in the current kernel session:

Out[3]=3
Out[5]=5

Remove the initialization value:

Scope  (1)Survey of the scope of standard use cases

Set an initialization value in the default persistence location:

Out[1]=1

Set an initialization value in the "KernelSession" persistence location:

The first value found in $PersistencePath is used:

Out[4]=4
Out[5]=5

Find all initialization values ever defined:

Out[6]=6

Generalizations & Extensions  (1)Generalized and extended use cases

Set an initialization value for parallel subkernels:

All newly launched parallel subkernels use the given value:

Out[3]=3

Remove the initialization value:

Options  (5)Common values & functionality for each option

EvaluationEnvironment  (1)

Set an initialization value for parallel subkernels:

MergingFunction  (1)

Give a default value for a variable:

Set a custom merging function for initialization values of the variable:

Out[2]=2

Specify initialization values at different persistence locations:

The custom merging function is used to return the list of all values on $PersistencePath:

Out[5]=5

Use a different merging function for a particular value lookup:

Out[6]=6

ValuePreprocessingFunction  (1)

Give a default value for an initialization value:

Set a a custom value preprocessing function that accepts only integers:

Out[69]=69

Assign an integer at any persistence location:

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

PersistenceTime  (1)

Define an initialization that will expire in 5 seconds:

Out[2]=2
Out[3]=3

ExpirationDate  (1)

Define an initialization value that expires at the beginning of next year:

Applications  (2)Sample problems that can be solved with this function

Override the default persistence base in all kernels started under the current front end session:

Quit and restart the kernel:

Out[3]=3

Set a value for $GeoLocation tied to your login account:

Properties & Relations  (2)Properties of the function, and connections to other functions

Initialization values are stored in persistent objects:

Out[2]=2

List the existing initialization values in all editable persistence locations:

Out[1]=1

Remove them:

Possible Issues  (1)Common pitfalls and unexpected behavior

Create two initialization values for a symbol in different locations:

Remove by default removes only the value in the location given by $PersistenceBase:

Out[3]=3

Remove all values that might exist anywhere in the locations given by $PersistencePath:

Out[5]=5
Wolfram Research (2017), InitializationValue, Wolfram Language function, https://reference.wolfram.com/language/ref/InitializationValue.html (updated 2019).
Wolfram Research (2017), InitializationValue, Wolfram Language function, https://reference.wolfram.com/language/ref/InitializationValue.html (updated 2019).

Text

Wolfram Research (2017), InitializationValue, Wolfram Language function, https://reference.wolfram.com/language/ref/InitializationValue.html (updated 2019).

Wolfram Research (2017), InitializationValue, Wolfram Language function, https://reference.wolfram.com/language/ref/InitializationValue.html (updated 2019).

CMS

Wolfram Language. 2017. "InitializationValue." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/InitializationValue.html.

Wolfram Language. 2017. "InitializationValue." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/InitializationValue.html.

APA

Wolfram Language. (2017). InitializationValue. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/InitializationValue.html

Wolfram Language. (2017). InitializationValue. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/InitializationValue.html

BibTeX

@misc{reference.wolfram_2025_initializationvalue, author="Wolfram Research", title="{InitializationValue}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/InitializationValue.html}", note=[Accessed: 07-June-2025 ]}

@misc{reference.wolfram_2025_initializationvalue, author="Wolfram Research", title="{InitializationValue}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/InitializationValue.html}", note=[Accessed: 07-June-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_initializationvalue, organization={Wolfram Research}, title={InitializationValue}, year={2019}, url={https://reference.wolfram.com/language/ref/InitializationValue.html}, note=[Accessed: 07-June-2025 ]}

@online{reference.wolfram_2025_initializationvalue, organization={Wolfram Research}, title={InitializationValue}, year={2019}, url={https://reference.wolfram.com/language/ref/InitializationValue.html}, note=[Accessed: 07-June-2025 ]}