7 Replies
These are functionally the same, its a matter of preference.
The minor difference is that the top one (primary constructor) lets you use the
item
and quantity
variables again, in which case they would get captured
and if they are captured and exposed as private fields, they are sadly not readonly, which is why I personally don't use primary ctors for non-recordsuh, idk if i understood it, what do you mean can be used again?
if they are captured and exposed as private fields, they are sadly not readonly
can you give an example of it being captured and exposed? idk what that is1 sec
Pobiega
REPL Result: Success
Console Output
Compile: 571.455ms | Execution: 46.756ms | React with ❌ to remove this embed.
there you go
A
gets the value from a
, as we intended
but a
still exists, and can be mutated and usedohh
got it, thank you!
Unknown User•2w ago
Message Not Public
Sign In & Join Server To View