July 29, 2020 is using predSwitch the only way to create to create recursive functions in D ? | ||||
---|---|---|---|---|
| ||||
,, |
July 29, 2020 Re: is using predSwitch the only way to create to create recursive functions in D ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andy Balba | On 7/29/20 3:13 PM, Andy Balba wrote:
> ,,
Not at all. The wording in the documentation is misleading.
Recursive functions are as trivial as they are:
int foo(uint i) {
if (i == 0) {
return 42;
}
return foo(i - 1);
}
void main() {
assert(foo(7) == 42);
}
Ali
|
Copyright © 1999-2021 by the D Language Foundation