Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

EQ vs. IS

New Here ,
Oct 20, 2006 Oct 20, 2006
I've been using EQ and NEQ for years for all kinds of comparisons on both strings and numeric (as have many of my peers at different places I've worked)

Today, I was told it was bad form to use EQ for a string comparison that IS should be used. I've been doing this for a long time so it was news to me.

So, here's my question - is it simply a matter of preference or is there genuinely a difference between EQ and IS in ColdFusion?

I didn't find anything on live docs other than them listing EQ and IS and EQUALS as being used to "test for equality".

Any insight is greatly appreciated.

3.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 20, 2006 Oct 20, 2006
> Today, I was told it was bad form to use EQ for a string comparison that IS
> should be used. I've been doing this for a long time so it was news to me.

It's ballocks, so I wouldn't be that concerned about not having heard about
it.

Strictly speaking, when comparing strings, one should use compare() or
compareNoCase() (depending on requirement). But EQ / IS work fine too.
They might be slightly slower, but not by a such a factor it's worth
worrying about.


> Any insight is greatly appreciated.

I think you should ask the person who told you this to qualify their
answer.

--
Adam
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Oct 20, 2006 Oct 20, 2006
LATEST
With CF5 and earlier, EQ could give false results. Not sure if this still applies with CF MX.

IS and EQ can still give unexpected results when comparing strings. See http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000909.htm.

They are also slower than the Compare functions.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources