emilybache / Racing-Car-Katas

Several code katas on a racing car theme
https://youtu.be/ldthYMeXSoI
MIT License
302 stars 351 forks source link

Incorrect comparation operator #78

Closed Endless8 closed 8 months ago

Endless8 commented 8 months ago

Comparing the two string like showed in the snippet of code below it's not a good way, unless you're comparing the instance of the string, but I don't think this is the case since String class is immutable.

public void send(String message)
{
    // ...
    if (message == DIAGNOSTIC_MESSAGE)
    // ...
}

It should be:

public void send(String message)
{
    // ...
    if (message.equals(DIAGNOSTIC_MESSAGE))
    // ...
}

The target class is TelemetryClient of project TelemetrySystem (Java version), line 44

emilybache commented 8 months ago

It's probably a translation error, the original code was in C# and string comparison is done differently there. Feel free to raise a pull request that fixes this.