5

Above all sorry about the title, couldn't find a good one. Please edit if you think of any

I stumbled upon this description about equals operator in Salesforce docs.

OPERATOR    NAME    DESCRIPTION
  ==       Equals   ... String comparisons that use the equals operator are case-sensitive

But in Developer Console I get the result as below.

'foo' == 'Foo' 
>>> True

My question is, am I missing something here?

1 Answer 1

6

That documentation is about Einstein Analytics, which has different semantics from other areas of Salesforce.

In Apex, the == operator is case-insensitive:

String comparison using == is case-insensitive.

Case-sensitive String comparison in Apex is done using String.equals(). Note also there's a few places where Apex does do case-sensitive String matching; List.contains() and Set.contains() are among them.

2
  • 1
    Exactly what I was going to say. The documentation is not about Apex.
    – Adrian Larson
    Commented Jul 27, 2018 at 13:48
  • A-ha! That's why.! Brain-fart hits hard at 5pm of Friday. Thanks. Will accept whenever timer lets me.
    – Lafexlos
    Commented Jul 27, 2018 at 13:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .