Fun surprising things

Jonathan Marler johnnymarler at gmail.com
Wed Oct 31 16:21:47 UTC 2018


On Wednesday, 31 October 2018 at 16:05:47 UTC, bachmeier wrote:
> 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.

https://www.youtube.com/watch?v=lbp6vwdnE0k&start=1296


More information about the Digitalmars-d mailing list