Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,149,975 members, 7,806,849 topics. Date: Wednesday, 24 April 2024 at 04:09 AM

Yoda Condition? - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Yoda Condition? (342 Views)

(2) (3) (4)

(1) (Reply)

Yoda Condition? by Karleb(m): 4:20pm On Jan 08, 2021
You might have probably seen something like this before now.

if (5 == $five);

It's called Yoda condition, you check the reverse.

I see this a lot in PHP codes and there are arguments as to why it is better than the normal comparison.

Personally, I don't like it.

Is it really necessary?
Re: Yoda Condition? by etoluw: 9:43am On Jan 09, 2021
Karleb:
You might have probably seen something like this before now.

if (5 == $five);

It's called Yoda condition, you check the reverse.

I see this a lot in PHP codes and there are arguments as to why it is better than the normal comparison.

Personally, I don't like it.

Is it really necessary?


it helps to avoid a bug where you mistakenly type "=" instead of "=="
Re: Yoda Condition? by The5DME(m): 2:20pm On Jan 26, 2021
Karleb:
You might have probably seen something like this before now.

if (5 == $five);

It's called Yoda condition, you check the reverse.

I see this a lot in PHP codes and there are arguments as to why it is better than the normal comparison.

Personally, I don't like it.

Is it really necessary?

check your mail.

(1) (Reply)

Mysql Users And Experts - I Need Your Help / We're Hiring React Native And Dot Com / Web Development

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 8
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.