Anonymous class

ag0aep6g via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 12 05:02:03 PDT 2016


On 10/12/2016 01:56 PM, tcak wrote:
> I feel like I remember that this was added to D a while ago, but I am
> not sure. Is it possible to create anonymous classes?
>
> public interface Runnable{
>     void run();
> }
>
>
> runIt( new Runnable(){
>     void run(){
>         /* do stuff */
>     }
> });

runIt(new class Runnable { void run() { /* do stuff */ }});

https://dlang.org/spec/class.html#anonymous


More information about the Digitalmars-d-learn mailing list