elementAtOrNone method

Option<String> elementAtOrNone(
  1. int index
)

Returns the character at the given index as a Some, or None if the index is out of bounds.

Implementation

Option<String> elementAtOrNone(int index) {
  if (index < 0 || index >= length) {
    return const None();
  }
  return Some(this[index]);
}