- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
_.isEqual("Frist","First")
Admin
Yes
Admin
Hardly a WTF. We've seen the unnecessary if dozens of time.
The rest could be the remains of some refactoring. At some point, areEqual probably contained custom logic that was replaced with lodash when it was introduced into the project. Changing hundreds or thousands of calls to areEqual all over the codebase would have been a lot of work (and maybe not even possible if this is public functionality in a library). Leaving an old API as an adapter to the new one is sensible in so many cases. Sure, it should be annotated as deprecated but that's about it.
Admin
Its also useful for debugging purposes, you can put a break point on the return true or return false as appropriate, it can be hard to debug an equals in a complex if statement.
Admin
The if is nonsense, but having a wrapper for an external library is often not nonsense, eg if you don't want your code base littered with hard-to-change external references when the time comes to change libraries (again).
Admin
Testing whether something isEqual to something_else is just as grammatically correct as whether 2 values areEqual.
Admin
Not necessarily! Consider the following...
In other words, Javascript won't bind the
this
value unless you immediately call the function (as opposed to, say, Python where you get the expected behavior). Now, maybe lodash refers to itself as_
instead ofthis
, but it's not something you should rely on in the general case, like the article implies.For an extra bonus WTF, try running that code snippet without the
"use strict";
pragma. And then realize thatwindow
is the holder for all global variables...Admin
No it's not. Now if you were to call it .isEqualTo, then maybe I would concede.
Admin
I'm reminded of a new joiner who was apparently an English major who joined a team as a programmer, and didn't last the first day because she kept insisting that:
someFunction("literal string", parameter)
was grammatically incorrect, and it should have been written:
someFunction("literal string," parameter)
and went round changing it whenever she saw it and then complained that the code didn't compile, and they needed to get a new C compiler which didn't have a bug in it.
Admin
Why not just this?
import { isEqual as areEqual } from lodash;
Admin
That's funny. It's thanks to my background as a programmer that I dislike the fact that in American English, a period always goes inside a quote at the end of a sentence. Even when quoting a special term, the correct way is always to quote "like this." You never quote "like this". That second version is correct in British English, not American English. And the American version bothers me.
Admin
Ouch, my brain! The programmer side of my brain is laughing while the editor side of my brain is going, "she has a point."
Admin
And for all those pirates pirating software,
Admin
It bothers me too and I'm American.
Admin
All WTFs areEqual(), but some areMoreEqual() than others.
Admin
Fuzzy pig logic :-)
Admin
Apparently anyone who claims to be the authority on English usage has a minimum required amount of irrationality. American editors irrationally place the ending quote mark to include punctuation that is not part of the quote. British editors irrationally retain an extra "u" in words like "color".
And many editors on both sides of the Atlantic try to force Latin grammar into English, with rules on split infinitives and "ending a sentence with a preposition." (That last one would not be right even if moving the preposition to somewhere after the object was not a normal English construction - as shown in countless jokes where someone responds to criticism about this by adding "you a**hole" to the end of the same sentence.)
Admin
It's even funnier because the convention of putting the final punctuation inside the quotes instead of outside hasn't any grammatical basis because it's a rule from typesetting as back in the day it made kerning easier.
Admin
Such rules are the sort of pedantic nonsense up with which one should not put!
Admin
The u in colour is irrational and extra? I guess it depends on pronunciation, in which case the American spelling (at least for southerners) would be "carlerr", and in Niw Zillund perhaps "killeh".
I noticed the Australian Siri giving navigation instructions pronounces "onto" as "onter" :-D
Admin
The real WTF, (at least if you didn't know about it, in which case it's awesome), is that in some languages "!=" isn't always defined as the opposite of "==". So two objects can be both equal and not equal, or not equal and not-not equal. Which is why if you define isEqual, you'd better define isn'tEqual too.
Admin
Apparently anyone who claims to be the authority on English usage has a minimum required amount of irrationality. American editors irrationally place the ending quote mark to include punctuation that is not part of the quote. British editors irrationally retain an extra "u" in words like "color".
It's not extra. English got the word from Anglo-Norman or French, not directly from Latin. Ditto for -ise vs. -ize, which is one of the few things the OED gets wrong.
Admin
OKAY.
Admin
Common usage trumps etymological exactitudes so it's not exactly wrong. Although I suppose we could question whether it's common usage, when i worked for a certain UK ministry they would reject publications, reports etc using the -ize form as being in American rather than British English.
Admin
Unfortunately
Arrrrrr
be not a verb in Pirate; you be looking forbe.equal()
.Admin
I advise you to advertise a tolerance for -ise endings.
Except for "burglarize", which is simply an abomination.