Skip to content
프로젝트

소개

불변 데이터를 업데이트합니다.

기타 프로젝트

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

Accessors

DocStable DocDev CI

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:

JuliaCon2020 Changing the immutable

Featured extensions

  • AccessorsExtra.jl [docs] introduces additional optics and related functions that are considered too opinionated or too experimental for inclusion in Accessors.

관련 프로젝트 살펴보기

불러오는 중…