Removing "optional" at the end of StackScript UDF?

Hi everyone,

I wrote a StackScript and have noticed that there is an "optional" at the end of every StackScript UDF.

I tried putting example="" but that did not work.

Anyone has any idea on how I can remove the "optional" word?

Thanks for any suggestions! :)

6 Replies

Just an update to all who are seeing this.

The following will work:

Once default attribute is used, the "optional" at the end of UDF will appear.

This is not very logical. The optional makes it seem like an optional argument… There should be a switch for optional versus mandatory arguments imho.

When you provide the "default=value" attribute, the UDF becomes optional. If you don't set a default, it will be required. Simple as that.


Why would setting a default value suddenly make a variable optional? Imho setting a default could as well mean the argument is mandatory…

I found some Stackscripts with 'optional="false"' in the UDF arguments, but that doesn't seem to do anything?

I am also confounded by this. Default values and optional parameters are not mutually exclusive. How can we eliminate the optional designation?

Default values and mandatory are mutually exclusive; they're the exact opposite of each other in this case, because there is no default default. If you give a default, then it takes over when nothing is provided, thus making the field optional. If you don't give a default, then the StackScript doesn't know what to set the field to if nothing is provided, thus making the field mandatory. There's no point in setting a default if the field needs to be mandatory, because the default would never be used (assuming it were possible to set a default and still have the field be mandatory).


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct