Comparing a single-character String to a char value

In prior releases, in a comparison of a char value to a single-character String, Gosu coerced the char value to a String object. In release 9, Gosu behavior has changed and this coercion does not occur. The comparison fails even if the two characters are the same. To ensure that the types of the values are compatible, create a char value by surrounding a character with single quotes. For example, consider the following code:
var str = "abc "
if (str.charAt(str.length - 1) == ' ') { // Valid comparison of char values
// if (str.charAt(str.length - 1) == " ") { // Invalid comparison of char to String
  print("Characters are the same")
} else {
  print("Characters are different")
}

See also