Mike Simmons wrote:Also if the substrings are just one character each, it's probably easier to use chars:
or
Actually, because we have a concise "not equals" operator "!=", but no con concise "not or" operator, I find the first code easier to understand. But either works.
Your two conditions are not the same. The first one, which is the accurate translation, returns true if either the first or the last character is not a space. The second (wrong) one, returns true unless the first or last character is a space. It's equivalent to
firstChar != ' ' && lastChar != ' ', which switches the boolean operator.