{"route":"/en-US-v0.14.1/reference/foundations/version/","title":"Version","description":"Documentation for the Version type.","part":null,"outline":[{"id":"summary","name":"Summary","children":[]},{"id":"constructor","name":"Constructor","children":[{"id":"constructor-components","name":"components","children":[]}]},{"id":"definitions","name":"Definitions","children":[{"id":"definitions-at","name":"At","children":[{"id":"definitions-at-index","name":"index","children":[]}]}]}],"body":{"kind":"type","content":{"name":"version","title":"Version","keywords":[],"oneliner":"A version with an arbitrary number of components.","details":"<p>A version with an arbitrary number of components.</p>\n<p>The first three components have names that can be used as fields: <code>major</code>,\n<code>minor</code>, <code>patch</code>. All following components do not have names.</p>\n<p>The list of components is semantically extended by an infinite list of\nzeros. This means that, for example, <code>0.8</code> is the same as <code>0.8.0</code>. As a\nspecial case, the empty version (that has no components at all) is the same\nas <code>0</code>, <code>0.0</code>, <code>0.0.0</code>, and so on.</p>\n<p>The current version of the Typst compiler is available as <code>sys.version</code>.</p>\n<p>You can convert a version to an array of explicitly given components using\nthe <a href=\"/en-US-v0.14.1/reference/foundations/array/\" title=\"`array`\"><code>array</code></a> constructor.</p>","constructor":{"path":[],"name":"version","title":"Construct","keywords":[],"oneliner":"Creates a new version.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Creates a new version.</p>\n<p>It can have any number of components (even zero).</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">version</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">version</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">version</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">4</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">version</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">4</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">version</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">3</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/171d7fe9db3c91b277e567ab934a88a9.png\" alt=\"Preview\"></div></div>","title":"Constructing versions"}},{"kind":"html","content":"<p>As a practical use case, this allows comparing the current version\n(<a href=\"/en-US-v0.14.1/reference/foundations/version/\"><code>sys<span class=\"typ-punct\">.</span>version</code></a>) to a specific one.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code>Current version: <span class=\"typ-pol\">#</span><span class=\"typ-pol\">sys</span><span class=\"typ-punct\">.</span><span class=\"typ-pol\">version</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-punct\">#</span><span class=\"typ-punct\">(</span>sys<span class=\"typ-punct\">.</span>version <span class=\"typ-op\">&gt;=</span> <span class=\"typ-func\">version</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">0</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">14</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">0</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span> <span class=\"typ-escape\">\\</span>\n<span class=\"typ-punct\">#</span><span class=\"typ-punct\">(</span><span class=\"typ-func\">version</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">3</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">2</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">0</span><span class=\"typ-punct\">)</span> <span class=\"typ-op\">&gt;</span> <span class=\"typ-func\">version</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">4</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">1</span><span class=\"typ-punct\">,</span> <span class=\"typ-num\">0</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/9abdaee6d68422e95c9d5c76afd7cdcf.png\" alt=\"Preview\"></div></div>","title":"Comparing with the current version"}}],"self":false,"params":[{"name":"components","details":[{"kind":"html","content":"<p>The components of the version (array arguments are flattened)</p>"}],"types":["int","array"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":true,"settable":false}],"returns":["version"],"scope":[]},"scope":[{"path":["version"],"name":"at","title":"At","keywords":[],"oneliner":"Retrieves a component of a version.","element":false,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Retrieves a component of a version.</p>\n<p>The returned integer is always non-negative. Returns <code>0</code> if the version\nisn't specified to the necessary length.</p>"}],"self":true,"params":[{"name":"index","details":[{"kind":"html","content":"<p>The index at which to retrieve the component. If negative, indexes\nfrom the back of the explicitly given components.</p>"}],"types":["int"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["int"],"scope":[]}]}}}