I'm trying to define a command such that if it's given one argument, it outputs \textbf{#1}\index{#1}, and if given two arguments it does \textbf{#1}\index{#2}. Essentially, I'd like by default it to index to the input, but if given an optional argument index to that instead. It'd also be nice if when given one argument it could automatically capitalize it (so \myIndex{word} would run \textbf{word}\index{Word}), but I haven't looked into this much.
From this answer, it seems like the package xifthen will give me what I want. Unfortunately, I'm not at all familiar with ifthenelse, so writing the following has been giving me errors:
\newcommand{\Def}[2][]{\textbf{#2}\index{%\ifthenelse{\isempty{#1}{#2}{#1}%}}
The specific errors I'm getting are file ended while scanning use of \@xargdef, and then various undefined control sequence errors from whenever I used \Def in my code already.

\ifthenelse{\isempty{#1}{\index{#2}}{\index{#1}}– egreg Oct 06 '16 at 20:44