Using static properties and methods of variable in its own initializer

Dave P. dave287091 at gmail.com
Thu Apr 10 14:35:49 UTC 2025


On Thursday, 10 April 2025 at 08:26:57 UTC, Dejan Lekic wrote:
> On Wednesday, 9 April 2025 at 19:47:43 UTC, Dave P. wrote:
>> [...]
>
> Is this not good enough for you?
> ```d
> void main(){
>    size_t y = size_t.sizeof;
> }
> ```
>
> In short, types few properties too, .sizeof being one of them. 
> Other properties are .alignof and .init . More about it: 
> https://dlang.org/spec/property.html#type

This is just a trivial example. In general, repeating the type 
twice is error prone.


More information about the Digitalmars-d mailing list