Sometimes we want an optional parameter

function doSomething(foo:Integer; bar:TObject=nil)
begin
    if bar <> nil then // do something optional with bar
    ....
end

How do I do the equivalent with a boolean, that allows me to differentiate between the two boolean values and "no value"?

function doSomething(foo:Integer; bar:Boolean=nil) // Won't compile
begin
    if bar <> nil then // do something optional with bar
end

Obviously this won't compile as a Boolean cannot be nil.

Basically, I want a parameter with three possible states; true, false or "unspecified".

Edit
Report