Mathematica 9 is now available
 Documentation / Mathematica / Built-in Functions / Programming / Scoping  /
EndPackage

  • EndPackage[ ] restores $Context and $ContextPath to their values before the preceding BeginPackage, and prepends the current context to the list $ContextPath.
  • Every call to EndPackage must be balanced by an earlier call to BeginPackage.
  • EndPackage is typically used at the end of a Mathematica package.
  • EndPackage returns Null.
  • EndPackage resets the values of both $Context and $ContextPath.
  • See the Mathematica book: Section 2.6.10.

    Further Examples

    Nested BeginPackages and EndPackages behave properly. Here we have two nested context changes.

    In[1]:=

    Out[1]=

    The first EndPackage restores the context that was current before the last BeginPackage.

    In[2]:=

    Out[2]=

    Another EndPackage restores the original context.

    In[3]:=

    Out[3]=

    See also the Further Examples for BeginPackage.


    Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
    THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
    SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.