On Thu, 27 Nov 2014 13:07:58 +0000
Suliman via Digitalmars-d-learn <digitalmars-d-learn@puremagic.com>
wrote:

> Full function look like this:
> 
> auto parseConfig()
> {
>       auto config = Ini.Parse(getcwd ~ "\\" ~ "config.ini");
>       string txtlinks = getcwd ~ "\\" ~ config.getKey("input_links");
>       if(!exists(txtlinks))
>       {
>               writeln("Can't find input file with list of links.");
>               return;
>       }
>       auto lines = File(txtlinks, "r").byLine;
>       return lines;
> 
> }
ah, that's it! as spec says, D determines function return value from
the first 'return' statement it seen. in your case this is `return;`,
so function return type is determined to be `void`.

if you doing `auto` functions, try to arrange your code so the first
`return` returning the actual value.

besides, your code is wrong anyway, 'cause you can't have function that
returns both "nothing" and "something". your first `return;` should
either return something, or must be changed to throwing some exception.

Attachment: signature.asc
Description: PGP signature

Reply via email to