27
Mar 10 '19
Now that's clever.
30
u/Title2ImageBot Mar 10 '19
Summon me with /u/title2imagebot | About | feedback | source | Fork of TitleToImageBot
12
13
17
u/El_Impresionante Mar 10 '19
i = 1
while(i--)
print("It works")5
13
u/iimorbiid Mar 10 '19 edited Mar 10 '19
As someone who is pretty new to programming can you correct me if I'm wrong but does this program just set counter to 0, and when run it says "it works" but then it adds 1 to the value making it false and "breaks" (ending the program)?
Edit: I read it again and realized I was wrong and now I am lost..
Edit2: ONCE IN A WHILE, I GET IT
Edit3: So it sets it to 0, loop starts and adds 1 and it prints 'it works' then adds 1 (so it's 2 now) and program breaks, right?
8
5
u/SDJMcHattie Mar 11 '19
This should be simpler:
var once = true;
while (once) {
once = false;
Console.Log(“It works”);
}1
Mar 10 '19
shouldnt you be setting counter to 0 in the loop?
2
u/iimorbiid Mar 10 '19
Read the title again then the code, the title is the punchline!
1
Mar 10 '19
follow the execution, it only works on the first while
edit: I didnt see the break
1
u/iimorbiid Mar 10 '19
It only works once.
The WHILE loop works ONCE
So it works ONCE in a WHILE (as the title says)
1
1
-4
0
Mar 10 '19
[deleted]
23
3
2
Jun 21 '19
Took you a while to realize
FTFY
2
u/--cheese-- Jun 21 '19
Y'wot? Why comment with nothing on a three-month-old post?
2
Jun 22 '19
Nothing? You didn't get the pun, eh?
2
u/--cheese-- Jun 22 '19
Ohh, it's a play on while. Nice one.
Sorry, your changing the s in realise to a z made me think you were just trying to 'correct' my spelling. Am accidental red herring.
2
Jun 22 '19
made me think you were just trying to 'correct' my spelling.
Haha, I figured, sorry about that.
Programmer dadjokes are in short supply these days, I had to comment on this .. :P
3
32
u/blazingKazama Mar 10 '19
Smartest click bait till the date.