find_option<T extends CandidType> method

T? find_option<T extends CandidType>(
  1. dynamic key
)

Candid subtyping rules state that an Option can be missing within a record if it is sent with a null-value. Use this function when looking for an Option in a Record. key can be a String or an int.

Implementation

T? find_option<T extends CandidType>(dynamic key) {
    if (this.containsKey(key)) {
        return CandidType.as_option<T>(this[key]!).value;
    }
    return null;
}