STRUCT with immutable fields
이 제출물을 팔로우합니다
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다
MATLAB's flexible nature is very convenient in most situations. However, this flexibility can also be the cause of hard-to-find bugs.
In many cases, it is desirable to have a data type which is CONST. That is, a datatype which cannot be changed after the first assignment. MATLAB has seen heavy criticism due to its lack of a CONST data type. Although the basic functionality of CONST variables can be achieved through a class with constant properties, that approach leaves much to be desired.
That is where this file comes in. It implements all the functionality of a basic, scalar MATLAB structure, but after a field has been added and assigned a value, that field can no longer be changed.
That means, it strikes a middle ground by offering the flexibility of adding fields dynamically, but disallowing *changing* of fields values.
A simple example session:
C = const; % empty const
C.myField = 'test'; % first assignment; OK
C.myField = 4; % ERROR!
Much more is possible; have a look at the function documentation inside const.m for more information.
인용 양식
Rody Oldenhuis (2026). CONST structure (https://github.com/rodyo/FEX-const/releases/tag/v1.3), GitHub. 검색 날짜: .
GitHub 디폴트 브랜치를 사용하는 버전은 다운로드할 수 없음
| 버전 | 퍼블리시됨 | 릴리스 정보 | Action |
|---|---|---|---|
| 1.3 | See release notes for this release on GitHub: https://github.com/rodyo/FEX-const/releases/tag/v1.3 |
||
| 1.2.0.0 | Improved error handling a little bit
|
||
| 1.1.0.0 | [linked to Github] |
||
| 1.0.0.0 |
