What is the difference between enum and shared immutable?

IGotD- nise at nise.com
Thu Oct 29 16:56:46 UTC 2020


On Thursday, 29 October 2020 at 16:45:51 UTC, Ali Çehreli wrote:
>
> import std;
>
> immutable string p;
>
> shared static this() {
>   p = environment["PATH"];  // <-- Run time
> }
>

Just to clarify, immutable is allowed to be initialized in ctors 
but not anything later than that? Moving p = environment["PATH"] 
to main would generate an error.



More information about the Digitalmars-d-learn mailing list