Skip to content

Instantly share code, notes, and snippets.

@jimmckeeth
Created June 5, 2024 22:57
Show Gist options
  • Save jimmckeeth/c42401433a332b12480abcc0ae521971 to your computer and use it in GitHub Desktop.
Save jimmckeeth/c42401433a332b12480abcc0ae521971 to your computer and use it in GitHub Desktop.
Using the ToString on a Boolean is weird
// function BoolToStr(B: Boolean; UseBoolStrs: Boolean = False): string;
Writeln('BoolToStr(??, True)'); // BoolToStr(??, True)
WriteLn('True = ' + BoolToStr(True, True)); // True = True
WriteLn('False = ' + BoolToStr(False, True)); // False = False
Writeln('BoolToStr(??, False)'); // BoolToStr(??, False)
WriteLn('True = ' + BoolToStr(True, False)); // True = -1
WriteLn('False = ' + BoolToStr(False, False)); // False = 0
// class function ToString(const Value: Boolean; UseBoolStrs:
// TUseBoolStrs = TUseBoolStrs.False): string;
Writeln('ToString()'); // ToString()
WriteLn('True = ' + True.ToString()); // True = -1
WriteLn('False = ' + False.ToString()); // False = 0
// Now how do you get the String of True or False?
Writeln('ToString(True)'); // ToString(True)
WriteLn('True = ' + True.ToString(True)); // True = -1
WriteLn('False = ' + False.ToString(True)); // False = -1
Writeln('ToString(False)'); // ToString(False)
WriteLn('True = ' + True.ToString(False)); // True = 0
WriteLn('False = ' + False.ToString(False)); // False = 0
// The Boolean argument is the value for the conversion
// instead it replaces the value it is called on.
// You have to use the scoped Enumeration TUseBoolStrs.True
Writeln('ToString(TUseBoolStrs.True)'); // ToString(TUseBoolStrs.True)
WriteLn('True = ' + True.ToString(TUseBoolStrs.True)); // True = True
WriteLn('False = ' + False.ToString(TUseBoolStrs.True)); // False = False
Writeln('ToString(TUseBoolStrs.False)'); // ToString(TUseBoolStrs.False)
WriteLn('True = ' + True.ToString(TUseBoolStrs.False)); // True = -1
WriteLn('False = ' + False.ToString(TUseBoolStrs.False)); // False = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment