Alias sleep(int) for Thread.sleep(dur!("seconds")( int ));

Steven Schveighoffer schveiguy at gmail.com
Wed Nov 13 16:22:14 UTC 2019


On 11/12/19 4:24 PM, Marcone wrote:
> I am using this function to sleep, but I want a simple Alias. How can I 
> alias this?
> 
> // Function sleep(int)
> void sleep(int seconds){
>      Thread.sleep(dur!("seconds")( seconds ));
> }
> 
> sleep(1); // Using function.

Thread.sleep(1.seconds); // not that bad imo.

You can also alias sleep into your namespace to avoid having to type Thread:

alias sleep = Thread.sleep;

sleep(1.seconds);

-Steve


More information about the Digitalmars-d-learn mailing list