{
"id": "fn-array-pluck",
"dataComponent": "array",
"heading": {
"title": "pluck",
"badges": ["Array", "PARTIAL"]
},
"synopsis": "Returns an array containing the value at the given key from each keyed array in a MixedArray. Missing keys yield _ (placeholder). Partial usage and placeholders supported.",
"codeBlocks": [
"extend(\"array\")\n\nobjs = [ [a:1, b:2], [a:3], [b:4], [a:5, b:6] ]\nsput(array:pluck(\"a\", objs))\n# => [1,3,_,5]\n\n# Partial usage:\npluckA = array:pluck(\"a\")\nsput(pluckA(objs))\n# => [1,3,_,5]\n\n# Placeholder:\npartial = array:pluck(_, objs)\nsput(partial(\"b\"))\n# => [2,_,4,6]"
],
"notes": [
"Takes up to 2 arguments: (key, array).",
"If only one argument or a placeholder is supplied, partial usage returns a function.",
"Returns MixedArray, each value from the key or _ if missing.",
"If the array is not a MixedArray of KeyedArrays, raises an error."
]
}