Not sure if this qualifies as advanced programming but the way I see it the normal user wouldn't worry about this. Anyways...
I was watching A GDC talk(3:40) and the speaker was talking about how they avoid string to string compares, but didn't go into details
So after some research I've come to the understanding that, A string when used to compare is a "magic number" and that's not good(?)
What people in this situation normally do is have a enum that holds a constant number that is a reference for the actual string and just compare those constants
in other cases some people hash the strings and compare the Hashes
An example of my code currently:
My question is Do I need to care about this or is just comparing strings fine? So far I've never encountered an issue comparing strings.
and if so What is the best way to go about solving this issue?
I was watching A GDC talk(3:40) and the speaker was talking about how they avoid string to string compares, but didn't go into details
So after some research I've come to the understanding that, A string when used to compare is a "magic number" and that's not good(?)
What people in this situation normally do is have a enum that holds a constant number that is a reference for the actual string and just compare those constants
in other cases some people hash the strings and compare the Hashes
An example of my code currently:
GML:
var text = "Cakes made with bees are not tasty"
switch(text)
{
case "Cakes made with bees are not tasty": game_end(); break;
case "Everything is cake": game_restart(); break;
default: break;
}
and if so What is the best way to go about solving this issue?