best/proper way to declare constants ?
someone
someone at somewhere.com
Thu Aug 5 02:27:03 UTC 2021
On Thursday, 5 August 2021 at 02:06:13 UTC, Steven Schveighoffer
wrote:
> On 8/4/21 9:14 PM, H. S. Teoh wrote:
>> Unless you have a specific reason to, avoid using `enum` with
>> string and
>> array literals, because they will trigger a memory allocation
>> *at every
>> single reference to them*, which is probably not what you want.
>
> Just want to chime in and say this is NOT true for string
> literals. Only array literals.
OK. Not for arrays then ... but for string literals ? which one
then ?
static immutable string fileName = "list.txt";
vs
enum fileName = "list.txt";
> -Steve
More information about the Digitalmars-d-learn
mailing list