On 04/17/2017 12:33 PM, H. S. Teoh via Digitalmars-d-learn wrote:
On Mon, Apr 17, 2017 at 12:05:19PM -0700, Ali Çehreli via Digitalmars-d-learn 
wrote:
[...]
auto byNode(const(Tree) tree) {
    alias RangeType = typeof(byNode(tree.root));

Could this possibly be simplified to:

        alias RangeType = typeof(return);

?

Thank you. That's much better but only if I restructure the code to use an if statement:

auto byNode(const(Tree) tree) {
    if (tree.root) {
        return byNode(tree.root);
    }
    else {
        alias RangeType = typeof(return);
        return new RangeType(() {});
    }
}

That works because the return type of the function is the first return statement. (My original code had only one return and that was the problem.)

Ali

Reply via email to