PageSourceSearch

https://buck2.build/assets/js/ade5a120.b0b65f00.js

js buck2.build collected 2026-10-03 20:38:05 UTC 4,695 bytes, 1 lines download raw bytes

1"use strict";(globalThis.webpackChunkwebsite=globalThis.webpackChunkwebsite||[]).push([[5418],{15799(e,t,n){n.r(t),n.d(t,{assets:()=>i,contentTitle:()=>r,default:()=>u,frontMatter:()=>o,metadata:()=>c,toc:()=>d});const c=JSON.parse('{"id":"api/bxl/SelectConcat","title":"SelectConcat","description":"In bxl, Select = bxl.SelectDict | bxl.SelectConcat. bxl.SelectConcat is a list-like object that represents a select. One example of this type is:","source":"@site/../docs/api/bxl/SelectConcat.md","sourceDirName":"api/bxl","slug":"/api/bxl/SelectConcat","permalink":"/docs/api/bxl/SelectConcat","draft":false,"unlisted":false,"tags":[],"version":"current","frontMatter":{},"sidebar":"apiSidebar","previous":{"title":"Result","permalink":"/docs/api/bxl/Result"},"next":{"title":"SelectDict","permalink":"/docs/api/bxl/SelectDict"}}');var l=n(74848),s=n(28453),a=n(56289);const o={},r="SelectConcat",i={},d=[{value:"SelectConcat.length",id:"selectconcatlength",level:2},{value:"SelectConcat.select_iter",id:"selectconcatselect_iter",level:2}];function h(e){const t={code:"code",h1:"h1",h2:"h2",header:"header",hr:"hr",li:"li",p:"p",pre:"pre",ul:"ul",...(0,s.R)(),...e.components};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(t.header,{children:(0,l.jsx)(t.h1,{id:"selectconcat",children:"SelectConcat"})}),"\n",(0,l.jsxs)(t.p,{children:["In bxl, ",(0,l.jsx)(t.code,{children:"Select = bxl.SelectDict | bxl.SelectConcat"}),". ",(0,l.jsx)(t.code,{children:"bxl.SelectConcat"})," is a list-like object that represents a select. One example of this type is:"]}),"\n",(0,l.jsx)(t.pre,{children:(0,l.jsx)(t.code,{className:"language-python",children:'["--flags"] + select({\n    "root//constraints:a": ["--foo"],\n    "root//constraints:b": ["--bar"],\n    "DEFAULT": ["baz"]\n})\n'})}),"\n",(0,l.jsx)(t.p,{children:"You can:"}),"\n",(0,l.jsxs)(t.ul,{children:["\n",(0,l.jsxs)(t.li,{children:["Iterate over the values of this object (e.g. ",(0,l.jsx)(t.code,{children:"for item in select_concat.select_iter():"}),")"]}),"\n",(0,l.jsxs)(t.li,{children:["Get the length (e.g. ",(0,l.jsx)(t.code,{children:"len(select_concat)"}),")"]}),"\n",(0,l.jsxs)(t.li,{children:["Check its type using ",(0,l.jsx)(t.code,{children:"isinstance(select_concat, bxl.SelectConcat)"}),"."]}),"\n"]}),"\n",(0,l.jsx)(t.p,{children:"Sample usage:"}),"\n",(0,l.jsx)(t.pre,{children:(0,l.jsx)(t.code,{className:"language-python",children:'def _impl_select_concat(ctx):\n    node = ctx.lazy.unconfigured_target_node("root//:select_concat").resolve()\n    attr = node.get_attr("select_attr")\n    for value in attr:\n        if isinstance(value, bxl.SelectDict):\n            for key, value in value.items():\n                ctx.output.print(f"{key} -> {value}")\n        else:\n            ctx.output.print(value)\n    ctx.output.print(attr[0])\n'})}),"\n",(0,l.jsx)(t.h2,{id:"selectconcatlength",children:"SelectConcat.length"}),"\n",(0,l.jsx)("pre",{class:"language-python",children:(0,l.jsxs)("code",{children:["SelectConcat.length: ",(0,l.jsx)(a.default,{to:"/docs/api/starlark/int",children:"int"})]})}),"\n",(0,l.jsx)(t.p,{children:"Returns the length of a SelectConcat, defined as the number of items being concatenated at the select level (not the total number of elements across all lists)."}),"\n",(0,l.jsxs)(t.p,{children:["For example, ",(0,l.jsx)(t.code,{children:'[1, 2] + select({"DEFAULT": [3, 4]}'})," returns 2 instead of 4.\nNote: You can use ",(0,l.jsx)(t.code,{children:"len()"})," to get the length too."]}),"\n",(0,l.jsx)(t.hr,{}),"\n",(0,l.jsx)(t.h2,{id:"selectconcatselect_iter",children:"SelectConcat.select_iter"}),"\n",(0,l.jsx)("pre",{class:"language-python",children:(0,l.jsx)("code",{children:"def SelectConcat.select_iter() -> list"})}),"\n",(0,l.jsx)(t.p,{children:"Return the values of the SelectConcat."}),"\n",(0,l.jsx)(t.p,{children:"Sample usage:"}),"\n",(0,l.jsx)(t.pre,{children:(0,l.jsx)(t.code,{className:"language-python",children:'def _impl_select_concat(ctx):\n    node = ctx.lazy.unconfigured_target_node("root//:select_concat").resolve()\n    attr = node.get_attr("select_attr")\n    for value in attr.select_iter():\n        ctx.output.print(value)\n'})})]})}function u(e={}){const{wrapper:t}={...(0,s.R)(),...e.components};return t?(0,l.jsx)(t,{...e,children:(0,l.jsx)(h,{...e})}):h(e)}},28453(e,t,n){n.d(t,{R:()=>a,x:()=>o});var c=n(96540);const l={},s=c.createContext(l);function a(e){const t=c.useContext(s);return c.useMemo(function(){return"function"==typeof e?e(t):{...t,...e}},[t,e])}function o(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(l):e.components||l:a(e.components),c.createElement(s.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.