Am I sure pretty any that linter warning a throw can of instead breaking flow the both of reading writing and.
Haha it took me a second to realize what you did there
Yoda conditions
91–100 of 116 posts
Re: Yoda conditions
#92Earlier quoted context omitted.
Furthermore, when we have a problem, if our solution is to have human beings simply remember to do it a different way, we then have two problems.
I find this quote very powerful. I'm thinking I could re-use it. Is it yours or if it's sourced from somewhere could you share the source?
"Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems."
Re: Yoda conditions
#93All linters and C compilers emit a warning when an assignment is made in a condition. There are zero reasons to use that ugly and unnatural Yoda notation in 2019.
It also reduces time in debugging as you catch it immediately.
Re: Yoda conditions
#94Re: Yoda conditions
#95Earlier quoted context omitted.
Are they really easier to read though? A lot of the time which variable being tested is obvious, so it makes sense to put the important information - the value - first.
> so it makes sense to put the important information Both sides of the equality check are equally important.
Re: Yoda conditions
#96Yoda conditionals are still very popular in the PHP/Wordpress space. I never got used to using them personally.
Re: Yoda conditions
#97Re: Yoda conditions
#98Am I sure pretty any that linter warning a throw can of instead breaking flow the both of reading writing and.
Despite the name, it isn't referring to Yoda's grammar form, it's just reversing things around "and" and "or". If you really have a problem telling that "x == y" is the same as "y == x" I suggest coming to a deeper, more complete understanding of the equality operator as a commutative operator where the order doesn't matter rather than thinking of it as "variable is? value", as so many students clearly pick up accide…
Re: Yoda conditions
#99All linters and C compilers emit a warning when an assignment is made in a condition. There are zero reasons to use that ugly and unnatural Yoda notation in 2019.
It's my favourite way of writing if statements.
Re: Yoda conditions
#100I know I'm in the minority, but I honestly never really understood why people get so up in arms about this. People keep saying it's so difficult to read, and I just don't understand why. I know that linters and such can catch this most of the time, but a lot of places I've seen don't use them. (I don't know why, that's a whole other discussion.) It just seems to me that it's something that keeps you from wasting time…
You must be young, friend. The holy wars that used to rage over just where to put curly brackets... (And then Python came along and was like, "U wot mate?", and there were had little wars over "syntactically-significant indentation" and tabs vs. spaces, and how many spaces ... And on, and on...)