isVowel method

  1. @useResult
bool isVowel()

Returns true if this single-character string is a vowel.

Implementation

@useResult
bool isVowel() {
  if (isEmpty || length != 1) {
    return false;
  }

  return switch (toLowerCase()) {
    'a' || 'e' || 'i' || 'o' || 'u' => true,
    _ => false,
  };
}