// Use None to represent absence of a value
function findUser(id: number): Option<User> {
const user = users.find(u => u.id === id);
return user ? Some(user) : None;
}
// None is a singleton, so you can compare by reference
const result = findUser(999);
if (result === None) {
console.log('User not found');
}
// Use with Option methods
const name = None.unwrapOr('Anonymous'); // 'Anonymous'
A constant representing the
Nonecase of anOption, indicating the absence of a value. This constant is frozen to ensure it is immutable and cannot be altered, preserving the integrity ofNonethroughout the application.