Message from @Tromb2ch2
Discord ID: 685698248408956949
lol that goes back to understanding it conceptually
a white board is your friend
Also there is an app on the phone I've been using and there are tests you can make and let other people take
Like 50% of the problems are knowing what x++ does compared to ++x
so entry level stuff
lookin into algorithm problems
Yeah but at the same time, whoever writes ++x is annoying
?
no
i prefer ++x if i have the option
even tho the compilier will optimize it probably
🤣
Wait what do you mean? Does compiler optimize that? They do 2 different things
If you don't keep the result it won't matter at all.
Nothing to optimize.
they effectively do the same thing, just what they return is different. ++x is one less instruction. a compiler may choose to take the statement x++ and optimize it to ++x if it wants.
Or rather, the compiler will know not to bother with the result, but the order in which in does the operation and keeps the result won't matter because it will be discarding the result.
Well depending how you use it
if it makes a difference in performance, then the compiler will often take care of it bascically
it might still matter on smaller embedded devices tho
Yes, but also, don't do that.
if youre doing something like:
```
arr[i++] = x;
arr[++i] = x;
```
then yes, but thats because they return different things
but after the statement "i" will still be the same value
regardless of ++i or i++
Like, know the distinction, but to make your code readable, it's generally best to increment values and then on a totally separate line examine the variable.
Oh I agree
I suppose in some situations it might be nice.
and dont ever write that monstrosity you just wrote @Tromb2ch2 lol
But if somebody was being all like "x+=++i" just for shits and giggles I'd be annoyed.
But the tests on there are people doing that
its conceptual
is why
That's like 50% of the tests
Because people are assholes
but you cant say they do different things.
I would never write that
they RETURN different things
they do the same thing
Yeah employment tests are trash. I would never give out tests that were theory heavy or tried to trick people.
I'd mostly just present a problem and have them talk through solving it.