Closed AlpacaMax closed 3 years ago
The reason it's like this is because we want to focus on teaching the collision check. If in addition to that we also teach that statements can be used as return value the reader might get overwhelmed with information. So I appreciate the effort but I will have to decline your PR. Though I do agree with placing the and
on the next line.
I see. But do you think it will be better if we have a follow-up after that code saying that the return part can be simplified into my implementation? I guess it will introduce less confusion.
Sure, we can do that.
Thanks!
No problem! However I just realized that you mentioned the exact same thing in chapter23. So do we also change that part just to maintain the consistency?(I'll open another PR for that)
Sorry to keep bothering you with these small details BTW. I just feel that they are important.
Perhaps change it into a reminder that return statements work like that?
Don't be sorry. I'm happy that you want to help.
Great! I'll start working on it when I have time.
BTW, I forgot to mention that in this PR I also changed chapter14, in which I moved 'and' to the front in checkCollision(). So you need to update that chapter on the website as well.
The return part in checkCollision() is changed and the new implementation is generally considered a better practice for 2 reasons:
and
operator is moved to the front of each condition. This improves the readability of the code as it is clearer what operator is used in the expressions. This is trivial in this code as each boolean expression connected byand
is very short. However considering a lot of the readers of this tutorial are beginners I think it's necessary to show them this type of "clean code" thinking.