randomOrNull method

T? randomOrNull()

Implementation

T? randomOrNull() {
  try {
    return this[Random().nextInt(length)];
  } catch (e) {
    return null;
  }
}