I was trying to make an if statement that checks a string but isn’t case sensitive, and I came across some weird behavior:
String str = "Hello World.";
void setup(){
println(str.toUpperCase()); //Outputs HELLO WORLD.
println(str.toUpperCase() == "HELLO WORLD."); //Outputs false
println(str.toUpperCase() == str.toUpperCase()); //Outputs false (?!)
//The same thing also happens to .toLowerCase()
}
Why do these second two print statements output false?
And how would I go about checking if a string matches in a condition which isn’t case sensitive?
Sidenote: this sort of code works in Javascript