[Resolved] Using , for argument default is ignored


#1

Edit: This was a misunderstanding on my part.

I have a method that is called like this:

I am trying to substitute the third argument with its default like so:

but I am unable to do so.

I am then given this warning:

This is despite the default value being a String, in fact it is equal to that of the String shown in the first message - “,”

The parser does not seem to recognise that I am trying to use the , substitute in this case and instead skips to the next argument’s value. The , substitute works with every other argument.

Is this a bug?

If an image of the method declaration would be helpful, please let me know.

Edit: I have found that using the default value for the fourth argument (which is true) rather than writing ‘true’ or ‘false’ explicitly allows me to use , for the third argument like so:


#2

Right, this is by design.

If you use a single comma, the parser just thinks you are separating arguments. To skip an argument you must use two or more commas together.

The “Default parameters and omitting arguments” section in the Primer in the SkookumScript online docs might help.


#3

I see, I did not know about this functionality.
Thanks for the help Noolarch! :slight_smile:


#4

You’re welcome!

BTW, thanks for going through the trouble of pasting images to get the syntax highlighting, though you can get syntax highlighting in this forum with text too.

Just wrap the :sk: code in triple backticks ``` then specify a language similar to SkookumScript such as JavaScript/js (we don’t have SkookumScript as a common syntax highlighting option yet).

```js
{1 2 3 4 5}.pureString(1 true "," true true)
```

Which looks like this:

{1 2 3 4 5}.pureString(1 true "," true true)

You can also do inline code snippets by wrapping any text that you want displayed as code in single backticks `some_code()` which looks like some_code(). It has less colouring, though it still looks pretty good.

This should be easier than pasting images and it is easier to quote and modify text code in replies too.


Failing to change a variable's value passed into a coroutine as an argument