I created my MWE with the help of this Q&A.
MWE:
\documentclass{article}
\usepackage{xifthen}% provides \isempty test
\newcommand{\GlobalDef}[1][]{ %
\ifthenelse{\isempty{#1}} %
{} %
{\xdef\GlobalDef{#1}}
} %
\begin{document}
This should be empty:\GlobalDef{}
\par
This should also be empty: \GlobalDef
This should say Argument: \GlobalDef{Argument}
\par
This should also say Argument: \GlobalDef
\end{document}
Output:
Issues:
\xdefis not registering as a global definition in this\ifthenelsestatement.- Why is there a mysterious space before
\GlobalDef{Argument}in the 3rd line of this output?

\newcommand{\GlobalDef}[1][]{ %, i.e. before the%character ... and there are other spurious spaces as well – Jan 10 '19 at 21:58Argument? – Bernard Jan 10 '19 at 21:58\GlobalDefmay redefine itself and so all subsequent calls after that may use a different definition. I'm not sure if that is intended. – moewe Jan 10 '19 at 21:59\GlobalDefis defined as a macro with an optional argument. So it should be called as\GlobalDef[Argument]ifArgumentis to be the argument. As you call it now, you just call\GlobalDefwithout its only optional argument and then after that have either an empty group{}or{Argument}. That means that you always hit the branch that is called for an empty argument and you never execute the\xdefin the example. Try calling\GlobalDef[]and\GlobalDef[Argument]to see what happens. I'm not sure the output makes sense, but it does what you tell it to do, – moewe Jan 10 '19 at 22:01