singleOrNull method

T? singleOrNull()

Implementation

T? singleOrNull() {
  if (length != 1) return null;
  return first;
}