What is the difference between enum and shared immutable?
Imperatorn
johan_forsberg_86 at hotmail.com
Thu Oct 29 17:21:22 UTC 2020
On Thursday, 29 October 2020 at 16:31:41 UTC, Ali Çehreli wrote:
> On 10/28/20 5:55 PM, matheus wrote:
>> On Wednesday, 28 October 2020 at 22:07:06 UTC, H. S. Teoh
>> wrote:
>>> ... (This is why it's a bad idea to use enum with an array
>>> literal, because every time it's referenced you get a new
>>> copy of the array.)
>>> ...
>>
>> Could you please give an example (Snippet) about this?
>>
>> Matheus.
>
> An amusing proof:
>
>
> void main() {
> enum arr = [ 1 ];
> assert(arr.ptr != arr.ptr); // Passes :)
> }
>
> Ali
Did you just violate the law of identity 👍
More information about the Digitalmars-d-learn
mailing list