79350511

Date: 2025-01-12 18:58:21
Score: 1.5
Natty:
Report link

I would like to add my response here alongside the esteemed answer provided by @Remy Lebeau above.
another solution using the Undoc Default in system unit:

class function TMaybe<T>.FromValue(aValue: T): TMaybe<T>;
begin
  if aValue <> Default(T) then
  begin
    Result := TMaybe<T>.Some(aValue);
  end else
  begin
    Result := TMaybe<T>.None;
  end;
end;
Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @Remy
  • Low reputation (1):
Posted by: MBen