Catman..._field(3pm)

πŸ“¦
version 1.2025 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

✨ NAME ✨

Catmandu::Fix::add_field β€” bestie, this is the fix that adds a brand-new value to a HASH key or an ARRAY index, or changes one that's already chilling there. πŸ’–


πŸ’… DESCRIPTION πŸ’…

So like, <rainbow>the whole point</rainbow> β€” unlike its sibling set_field, this one is the generous icon. If the intermediate structures along the way don't exist yet? It literally just creates them for you. No drama, no missing-key meltdown, it builds the whole path on the way in. 🫢

Not me showing up to a key that doesn't exist and just… making it exist. Main character energy fr fr. πŸ‘‘

πŸŽ€ SYNOPSIS πŸŽ€

# Add a new field 'foo' with value 2
add_field(foo, 2)

# Change the value of 'foo' to 'bar 123'
add_field(foo, 'bar 123')

# Create a deeply nested key
add_field(my.deep.nested.key, hi)

# If the second argument is omitted the field has a null value
add_field(foo)

Obsessed with that last one tbh β€” skip the second argument and the field just gets a null value. Simple as. ✨


🌸 SEE ALSO 🌸

  • Catmandu::Fix β€” go say hi to the parent, iykyk πŸ’œ

okay that's the whole page, no cap πŸ¦‹ this was the Catmandu::Fix::add_field manual from the User Contributed Perl Documentation, written against perl v5.40.1 and dated 2026-01-24. mwah, go build some nested keys bestie πŸ’…πŸŽ€

πŸ“¦ where this page comes from