Non-ugly ways to implement a 'static' class or namespace?

Ruby The Roobster rubytheroobster at yandex.com
Fri Jan 20 13:17:05 UTC 2023


On Friday, 20 January 2023 at 13:03:18 UTC, thebluepandabear 
wrote:
> ll
>> a function without instantiating said class, as functions act 
>> on the class object.
>
> Ok, thanks.
>
> I think D should implement something similar to `static class` 
> but I doubt it will happen.

D isn't Java, and never will be.  If you want similar 
functionality, you put the functions in a separate file, and add 
the line to the top of it:

```d
module modulename;
```

and title the file modulename.d.  Then you can use this module as 
a .class file in java by adding

```d
import modulename;
```

to the file that uses it.


More information about the Digitalmars-d-learn mailing list