What Does This Mean in Documentation: Square Bracket Followed by Comma ( [, )

What does this mean in documentation: square bracket followed by comma ( [, )

It means that parameter is optional. You don't have to provide it and if you don't it will use the value you see listed there by default.

What does the brackets with comma around input arguments mean in python documentations?

It's a common convention in documentation to denote optional arguments with square brackets. That documentation is telling you that the second argument to boxPoints is optional. It has no syntactic meaning in Python; you can call the function with one or two arguments like normal.

Why do Python function docs include the comma after the bracket for optional args?

The square bracket means that the contents are optional, but everything outside of square brackets is compulsory.

With your notation:

RegexObject.match(string, [pos], [endpos])

I would expect to have to write:

r.match("foo",,)

The nesting is required because if you supply the third parameter then you must also supply the second parameter even though it is an optional parameter. The following non-nested alternative would be ambiguous:

RegexObject.match(string[, pos][, endpos])

Comma in front of square bracket - MDN docs

The square brackets mean that the enclosed parameter is optional.

Refer MDN syntax section for more info.

What does it mean in documentation when arguments are in square brackets?

It means optional arguments.

It is not python specific syntax, it is more general grammar notation syntax, for example, from https://en.wikipedia.org/wiki/Extended_Backus–Naur_form:

Many BNF specifications found online today are intended to be human-readable and are non-formal. These often include many of the following syntax rules and extensions:

Optional items enclosed in square brackets: [].

Better explanation in https://en.wikipedia.org/wiki/Extended_Backus–Naur_form, Basics chapter.

JavaScript: comma after opening bracket of parameter in syntax example

The brackets themselves mean "optional", and the = 0 gives the default value should you decide to omit that parameter. The reason why the comma is inside the brackets is because it forms part of the optional bit - if the second parameter is omitted, so is the comma.

In other words, you can use indexOf with only searchElement, in which case fromIndex is assumed to be zero. Or you can specify your own value for fromIndex if you don't want to start searching at element number zero.

So the first two below are equivalent while the third will start searching at a different point in the array:

x = haystack.indexOf (needle);
x = haystack.indexOf (needle, 0);
x = haystack.indexOf (needle, 42);

The Mozilla Developer Network has this to say on the matter (my emphasis):

fromIndex: The index to start the search at.

If the index is greater than or equal to the array's length, -1 is returned, which means the array will not be searched. If the provided index value is a negative number, it is taken as the offset from the end of the array.

Note: if the provided index is negative, the array is still searched from front to back. If the calculated index is less than 0, then the whole array will be searched.

Default: 0 (entire array is searched).

What do the brackets around the arguments mean when reading documentation for a method?

required [optional] <required> [<optional>, <but both needed>].

This is almost always the case.

why does jquery ajax syntax use commas inside the bracket of each argument?

Because what you're looking at is usage documentation, not actual JS syntax. The convention in most programming documentation is to use surrounding square brackets to denote optional parameters. If you remove the parameter, you'll want to remove the comma too, so it's included inside the bracket.



Related Topics



Leave a reply



Submit