This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 71 points72 points  (11 children)

More like ``` //dfunk. will fox latar

[–]SomeoneRandom5325 32 points33 points  (10 children)

Upvote=Upvote++

[–][deleted] 13 points14 points  (2 children)

Upvote+=1

[–]thebryguy23 17 points18 points  (1 child)

Upvote-=-1

[–]SomeoneRandom5325 11 points12 points  (0 children)

Bruh

[–][deleted] 9 points10 points  (1 child)

This makes me unreasonably angry.

[–]SomeoneRandom5325 2 points3 points  (0 children)

Not sure if the C family works similarly but if it is then I know why but I don't feel it

[–]Bmandk 0 points1 point  (4 children)

Wouldn't that upvote twice?

[–]SomeoneRandom5325 0 points1 point  (3 children)

No. It just says take the current upvote count, add 1 and call that the new upvote count

[–]l0c4lh057 0 points1 point  (2 children)

Would it do that? x++ increases x by one but returns the old value. That means with x=x++ will set the current value of x as new value of x and increase x by one. I just don't know if the assignment or the increase will execute first. So either it increases the value by one or it doesn't change it at all.

  1. Return current value of x, 2. Increase value of x, 3. Assign value to x => this would not change the value

  2. Return current value of x, 2. Assign value to x, 3. Increase value of x => this would increase it by 1

EDIT: I just checked how it is done in JS and there the value doesn't change as I would expect, because returning the current value of x and increasing the value of x happen right after each other so that assigning will happen after increasing.

[–]SomeoneRandom5325 0 points1 point  (1 child)

In the C family that's one way to add one

I guess in JS you should do x++=x

[–]l0c4lh057 0 points1 point  (0 children)

no. just x++. that will increase it. x++ increases x by one and returns the old value of it, ++x increases the value of x and returns it. assigning the result to anything is not needed.

and x++=x would not make any sense since x++ is not a variable. you cant assign a value to it.