문제

Does anyone know if subj will be implemented? At least, auto storage class for them? Thanks!

도움이 되었습니까?

해결책

There are various problem with auto functions in general, so it could very well be that you can't do

void main()
{
    auto bar() { return "hello world"; }

    writeln(bar());
}

because of a bug with auto rather than it being as designed. I'm not sure what the exact plans for that are, though I would think that you would supposed to be able to use auto as the return type of a nested function. There is an enhancement request on it in either case.

However, regardless of whether auto works with nested functions, you can declare a delegate in a similar manner:

void main()
{
    auto bar = () { return "hello world"; };

    writeln(bar());
}

So, the basic functionality is still there, even if the exact syntax that you were looking for doesn't currently work.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top