How To: Passing curried functions around
Bahman Movaqar via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Sep 11 13:07:41 PDT 2015
On Friday, 11 September 2015 at 18:39:15 UTC, Ali Çehreli wrote:
> >> import std.stdio;
> >>
> >> bool isEven(int n) {
> >> return !(n % 2);
> >> }
> >>
> >> int readValidInt(alias validator)(string prompt) {
>
> readValidInt() is a function template that takes two
> information:
>
> 1) The validator as its alias template parameter. alias
> template parameter allows it to work with anything that can be
> called.
I read "alias and with" chapter of the book to understand this
but couldn't find any such use for `alias` there. Does using
`alias` instead of a type makes the parameter a `callable`?
More information about the Digitalmars-d-learn
mailing list