mercredi 26 août 2015

Why is it good practice to use String.empty? [duplicate]

From what I've seen on several Stack Overflow posts, something like

if (str == "") 

should instead be

if (str == String.empty)

which is of course more descriptive and, I guess, maintanable. But what is the chance that the definition of an empty string is going to change at some point in the future? Some day in the future, is an empty string going to be defined as something other than a string with zero characters in it, so that we can all recompile our code and it'll work with our society in which an empty string is not the same as "" ????

Aucun commentaire:

Enregistrer un commentaire