PageSourceSearch

https://noir-lang.org/docs/assets/js/a57a1106.2b0d7f53.js

js noir-lang.org collected 2026-10-03 22:52:22 UTC 3,430 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkdocs=globalThis.webpackChunkdocs||[]).push([[2125],{89419(e,t,n){n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>r,default:()=>u,frontMatter:()=>o,metadata:()=>s,toc:()=>l});const s=JSON.parse('{"id":"language/data_types/tuples","title":"Tuples","description":"Dive into the Tuple data type in Noir. Understand its methods, practical examples, and best practices for efficiently using Tuples in your Noir code.","source":"@site/versioned_docs/version-v1.0.0-rc.0/language/data_types/tuples.md","sourceDirName":"language/data_types","slug":"/language/data_types/tuples","permalink":"/docs/v1.0.0-rc.0/language/data_types/tuples","draft":false,"unlisted":false,"editUrl":"https://github.com/noir-lang/noir/edit/master/docs/versioned_docs/version-v1.0.0-rc.0/language/data_types/tuples.md","tags":[],"version":"v1.0.0-rc.0","frontMatter":{"title":"Tuples","description":"Dive into the Tuple data type in Noir. Understand its methods, practical examples, and best practices for efficiently using Tuples in your Noir code.","keywords":["noir","tuple type","methods","examples","multi-value containers"]},"sidebar":"sidebar","previous":{"title":"Vectors","permalink":"/docs/v1.0.0-rc.0/language/data_types/vectors"},"next":{"title":"Structs","permalink":"/docs/v1.0.0-rc.0/language/data_types/structs"}}');var a=n(74848),i=n(28453);const o={title:"Tuples",description:"Dive into the Tuple data type in Noir. Understand its methods, practical examples, and best practices for efficiently using Tuples in your Noir code.",keywords:["noir","tuple type","methods","examples","multi-value containers"]},r=void 0,c={},l=[];function d(e){const t={code:"code",p:"p",pre:"pre",...(0,i.R)(),...e.components};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(t.p,{children:"A tuple collects multiple values like an array, but with the added ability to collect values of\ndifferent types:"}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-rust",children:"fn main() {\n    let tup: (u8, u64, Field) = (255, 500, 1000);\n}\n"})}),"\n",(0,a.jsx)(t.p,{children:"One way to access tuple elements is via destructuring using pattern matching:"}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-rust",children:"fn main() {\n    let tup = (1, 2);\n\n    let (one, two) = tup;\n\n    let three = one + two;\n}\n"})}),"\n",(0,a.jsxs)(t.p,{children:["Another way to access tuple elements is via direct member access, using a period (",(0,a.jsx)(t.code,{children:"."}),") followed by\nthe index of the element we want to access. Index ",(0,a.jsx)(t.code,{children:"0"})," corresponds to the first tuple element, ",(0,a.jsx)(t.code,{children:"1"})," to\nthe second and so on:"]}),"\n",(0,a.jsx)(t.pre,{children:(0,a.jsx)(t.code,{className:"language-rust",children:"fn main() {\n    let tup = (5, 6, 7, 8);\n\n    let five = tup.0;\n    let eight = tup.3;\n}\n"})})]})}function u(e={}){const{wrapper:t}={...(0,i.R)(),...e.components};return t?(0,a.jsx)(t,{...e,children:(0,a.jsx)(d,{...e})}):d(e)}},28453(e,t,n){n.d(t,{R:()=>o,x:()=>r});var s=n(96540);const a={},i=s.createContext(a);function o(e){const t=s.useContext(i);return s.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function r(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:o(e.components),s.createElement(i.Provider,{value:t},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.