InitializationObject[sym,loc]
gives the persistent object where InitializationValue[sym,loc] is stored.
InitializationObject["context`name",loc]
gives the persistent object where the initialization value for the symbol with the specified complete name is stored.
InitializationObject
InitializationObject[sym,loc]
gives the persistent object where InitializationValue[sym,loc] is stored.
InitializationObject["context`name",loc]
gives the persistent object where the initialization value for the symbol with the specified complete name is stored.
Details and Options
- In InitializationObject[sym,loc], possible forms for the persistence location loc include:
-
PersistenceLocation["type"] "Local", "Cloud", "FrontEndSession", etc. locations "type" equivalent to PersistenceLocation["type"] PersistenceLocation["type","base"] location with a particular base (directory etc.) "type""base" equivalent to PersistenceLocation["type","base"] - Supported location types include:
-
"KernelSession" current invocation of the Wolfram Language kernel "FrontEndSession" current invocation of the Wolfram Notebook front end "Local" local to a computer, based on user home directory "LocalShared" local to a computer, based on $BaseDirectory "Cloud" in the cloud defined by the current $CloudBase "Installation" installation defaults
Examples
open all close allBasic Examples (2)
Set an initialization value for a variable:
InitializationValue[Global`myvar, "KernelSession"] = 42;Get the persistent object where the initialization is stored:
io = InitializationObject[Global`myvar, "KernelSession"]Give all properties of the initialization object:
io[All]The full name of the variable can be given as a string:
InitializationObject["Global`myvar", "KernelSession"]Applications (2)
Give a default value for a variable:
InitializationValue[ivar, "Local"] = {};Set a custom merging function for initialization values of the variable:
io = InitializationObject[ivar, "Local"]io["MergingFunction"] = Flatten;Specify initialization values at different persistence locations:
InitializationValue[ivar, "KernelSession"] = 2;
InitializationValue[ivar, "FrontEndSession"] = 3;The custom merging function is used to return the list of all values on $PersistencePath:
InitializationValue[ivar]When the variable is initialized, the default merging function is also used:
Initialize[ivar];
ivarGive a default value for an initialization value:
InitializationValue[var3, "Local"] = 0;Set a a custom value preprocessing function that accepts only integers:
validateInteger[x_] := If[IntegerQ[x], x, $Failed]io = InitializationObject[var3, "Local"]io["ValuePreprocessingFunction"] = validateInteger;Assign an integer at any persistence location:
InitializationValue[var3, "FrontEndSession"] = 2;Assigning anything else generates an error, and the assignment is not performed:
InitializationValue[var3, "Local"] = 1.5;InitializationValue[var3]Properties & Relations (1)
Create two initialization values for a symbol in different locations:
InitializationValue[Global`myvar, "KernelSession"] = 42;
InitializationValue[Global`myvar, "Local"] = 43;InitializationObjects gives all initialization objects found on $PersistencePath:
InitializationObjects[Global`myvar]InitializationObject is used to access a specific object in a given persistence location:
InitializationObject[Global`myvar, "KernelSession"]It can be used to find properties of the given initialization object:
InitializationObject[Global`myvar, "KernelSession"][All]History
Text
Wolfram Research (2021), InitializationObject, Wolfram Language function, https://reference.wolfram.com/language/ref/InitializationObject.html.
CMS
Wolfram Language. 2021. "InitializationObject." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/InitializationObject.html.
APA
Wolfram Language. (2021). InitializationObject. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/InitializationObject.html
BibTeX
@misc{reference.wolfram_2026_initializationobject, author="Wolfram Research", title="{InitializationObject}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/InitializationObject.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_initializationobject, organization={Wolfram Research}, title={InitializationObject}, year={2021}, url={https://reference.wolfram.com/language/ref/InitializationObject.html}, note=[Accessed: 12-June-2026]}