[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

give me a scenario where === is true but == isn't

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 27
Thread images: 3

File: 5ttlR.png (8KB, 737x221px) Image search: [Google]
5ttlR.png
8KB, 737x221px
give me a scenario where === is true but == isn't
>>
>>56664777
You just posted one in your pic ffs
>>
>>56664799
can you read ?
>>
>>56664777
There is literally no reason to use ==.
>>
OP === "faggot"
OP == "faggot"

My bad, this is always true.
>>
OP === faggot
OP == not a faggot

yw.
>>
>>56664777
I don't know what language that is, but I would think none exist; equal to would better be defined as "equal value".
>>
I'm pretty sure === is (value == value && type==type) so any === evaluating to true would mean that == has to be true. But I'm not familiar with the language, so don't quote me with that.
>>
Is this a language that I can override an object's .equalsTo() and .type() methods? Then maybe depending on the implementation of ===
>>
>>56664777
Looks like the PHP manual page.. for all those asking what language
>>
>>56664777
x = "5"
"5"
x === 5
false
x == 5
true
>>
>>56664777
x = 5

x == "5"
x === "5"

this is not a hard concept
>>
>>56665229
not that.
>>
File: 1474217953900[1].jpg (68KB, 799x534px) Image search: [Google]
1474217953900[1].jpg
68KB, 799x534px
>>
>>56664929
>>56665112
>>56665167
>>56665172
Javascript
>>
>>56665332
I don't know javascript, can I override the type and value checks?
>>
>>56665272
Return false
>>
>>56665112
This.
>>
>>56664809
Can you?

Do you not know what a type is?
>>
File: ====.png (54KB, 588x275px) Image search: [Google]
====.png
54KB, 588x275px
>>
>>56664777
Firstly its important to know why those two operators are different.

== will try to convert the types to be the same then compare their values.

=== will not convert types and just check if they're equal

So it doesn't make sense that === would be true and == is not unless the language is fundamentally broken.
>>
>>56665237
>>56665411
Reading is hard.
>>
>>56664777
>x = 5
>!(x === "5")
true
>!(x == "5")
false
>>
>>56666705
kill yourself
>>
I can accept that there is = for assignment and == for comparison, but you better have good syntax highlighting to catch whether you are using one or the other.
But why would you add fuzzy implementations?
When would you use this for other things than on strings?
And on strings, wouldn't you have something more than numbers in the string?
And if you already have to get the value, would it be too weird to make a conversion in all places?

What would the fourth be used for?
>>
>>56664799
FPBP op can't handle the bantz
>>
>>56667353
It could happen in the most pathological of situations.
A:
>f(x) == f(y)
B:
>g(x) == g(y)

If g modifies the values of x and y so that A would be true when it wasn't before g then it could work.
Thread posts: 27
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.