Fun surprising things

bachmeier no at spam.net
Wed Oct 31 16:05:47 UTC 2018


On Wednesday, 31 October 2018 at 14:00:14 UTC, bauss wrote:
> What's the output of this program? (Try to figure it out 
> without running it.)
>
> ```
> int c = 0;
>
> int a()
> {
>     return c++;
> }
>
> int b()
> {
>     return c--;
> }
>
> void main()
> {
>     import std.conv : to;
>     import std.stdio : writeln;
>
>     writeln(to!string(a) ~ to!string(b));
> }
> ```
>
> If your answer is "10" then you're wrong.
>
> You can get the result and answer here: 
> https://run.dlang.io/is/idZurR

Hopefully the pain of working with such code teaches one to not 
write such code. Yes, you can write FORTRAN in D, but that 
doesn't mean it's a good idea to do so.


More information about the Digitalmars-d mailing list