Empty Result
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Apr 17 15:10:53 PDT 2017
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
More information about the Digitalmars-d-learn
mailing list