Why can object initializes assign 'init' but not 'readonly' #8409
Answered
by
huoyaoyuan
zms9110750
asked this question in
General
-
Isn't init used as a substitute for readonly on property? Why does he have an additional permission? |
Beta Was this translation helpful? Give feedback.
Answered by
huoyaoyuan
Sep 6, 2024
Replies: 1 comment 1 reply
-
No. Getter-only auto properties corresponds to
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
zms9110750
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No. Getter-only auto properties corresponds to
readonly
fields. They can be assigned in constructor.readonly
means it can only be set by the object itself, in constructor.init
allows initialization from the caller that uses the object.