This is a stripped-down version of a single section of Grok TiddlyWiki, optimized for fast loading and readability by search engines. Some features are missing.

For the full Grok TiddlyWiki experience, please visit the wiki version of this page.

Ex:ReversedOptionalParameters/answer

 10th October 2024 at 8:12am

After reversing, we get something like this:

\procedure wikipediaLink(linkText:"Wikipedia Link", articleName)
  <a href=`https://en.wikipedia.org/wiki/$(articleName)$`>
  <<linkText>></a>
\end

<<wikipediaLink Aardvark>>
<<wikipediaLink "Wikipedia on aardvarks" Aardvark>>

In the first link, we can see that articleName has implicitly gotten a value of "" (an empty value), because there is nothing after the wiki/. In fact, the same thing happens if you don't provide any default value at all and just don't include a parameter:

\procedure wikipediaLink(linkText, articleName)
  <a href=`https://en.wikipedia.org/wiki/$(articleName)$`>
  <<linkText>></a>
\end

<<wikipediaLink Aardvark>>

This said, putting non-optional parameters after optional ones, or calling a procedure with some non-optional parameters missing, is bad style and will likely get you very confused sooner or later, so you should certainly avoid it!

Go to question: Ex:ReversedOptionalParameters