These checks can all be simplified into `string.length == 0` (or `!=` or whatever), which implies a `nil` check as well.