On Sat, May 27, 2023 at 05:49:27PM +0000, vushu via Digitalmars-d-learn wrote:
> On Saturday, 27 May 2023 at 16:38:43 UTC, Steven Schveighoffer wrote:
[...]
> > void make_lava(T)(ref T lava) if (hasMagma!T) {
> >     lava.magma();
> > }
> > 
> > void make_lava(T)(ref T lava_thing) if (!hasMagma!T){
> >     lava_thing.try_making_lava();
> > }
[...]
> I see thanks for the example :), I think this probably the closest
> equivalent i dlang.

You can also use static if inside the function, which will give you an
if-then-else structure:

        void make_lava(T)(ref T lava) {
                static if (hasMagma!T) {
                        lava.magma();
                } else {
                        lava_thing.try_making_lava();
                }
        }


T

-- 
Written on the window of a clothing store: No shirt, no shoes, no service.

Reply via email to