Accessors.jl
Update immutable data
Install / Use
/learn @JuliaObjects/Accessors.jlREADME
Accessors
The goal of Accessors.jl is to make updating immutable data simple. It is the successor of Setfield.jl.
Usage
Say you have some immutable data structure, such as a NamedTuple:
julia> nt = (a=1, b=2)
(a = 1, b = 2)
If you try something like nt.b=3, it will throw an error. But
using Accessors, we can change it anyways:
julia> using Accessors
julia> @set nt.b=3
(a = 1, b = 3)
Note that this only returns an updated copy of nt, and does not overwrite or mutate the
value bound to nt:
julia> nt
(a = 1, b = 2)
To overwrite the old definition, we can rebind nt to the new version:
julia> nt = @set nt.b=3
(a = 1, b = 3)
julia> nt
(a = 1, b = 3)
As this is a common use case, the convenience macro @reset rebinds the variable (nt) to the updated version:
julia> @reset nt.b=4
(a = 1, b = 4)
julia> nt
(a = 1, b = 4)
For more detail, see this tutorial and/or watch this video:
Featured extensions
- AccessorsExtra.jl [docs] introduces additional optics and related functions that are considered too opinionated or too experimental for inclusion in
Accessors.
Related Skills
node-connect
347.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.2kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。

