Begin
Begin["context`"]
resets the current context.
Examples
open allclose allBasic Examples (1)
Define a function f in the MyContext` Context:
f will generally be hidden in the restored context:
Applications (1)
Make symbols used for package function definitions private, reducing the possibility for conflict:
Any use of the symbol f in the package context ensures that f is created in that context:
When the context given to Begin starts with ` it extends from the current context:
Since the symbol f is in the package context, the function works after EndPackage:
You can see that the other variable uses the private context:
Properties & Relations (3)
Begin["cont`"] sets $Context to "cont`":
End restores $Context to its value before the matching Begin:
Unlike BeginPackage, Begin does not modify $ContextPath:
Similarly, End does not modify it, either:
Begin does not alter the value of $ContextAliases:
End restores $ContextAliases to its value before the matching Begin:
Text
Wolfram Research (1988), Begin, Wolfram Language function, https://reference.wolfram.com/language/ref/Begin.html.
CMS
Wolfram Language. 1988. "Begin." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Begin.html.
APA
Wolfram Language. (1988). Begin. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Begin.html