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

Daniel Kozak kozzi11 at gmail.com
Tue Nov 12 22:26:48 UTC 2019


On Tuesday, 12 November 2019 at 21:24:54 UTC, 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.

You can do this:

import std.functional;
import core.time;
import core.thread;

alias sleep = compose!(Thread.sleep, dur!("seconds"));

void main()
{
     sleep(10);
}


More information about the Digitalmars-d-learn mailing list