String.match(regexp) JSDoc Oddity

Questions, tips and tricks and techniques for scripting in Servoy

String.match(regexp) JSDoc Oddity

Postby kwpsd » Wed May 31, 2017 2:22 am

string.match(regexp) returns an array of strings. So the proper JSDoc nomenclature should be @return{String[]}, but Servoy creates a warning marker:

servoy_regex_match_1.png
servoy_regex_match_1.png (24 KiB) Viewed 650 times


Changing the JSDoc nomenclature to @return{String} makes the warning maker go away but is not correct.

servoy_regex_match_2.png
servoy_regex_match_2.png (19.12 KiB) Viewed 650 times


Am I missing something?
Kim W. Premuda
San Diego, CA USA
User avatar
kwpsd
 
Posts: 567
Joined: Sat Jul 28, 2007 6:59 pm
Location: San Diego, CA USA

Re: String.match(regexp) JSDoc Oddity

Postby vschuurhof » Thu Jun 22, 2017 12:26 pm

It seems you are close. But the JSDoc notation in Servoy should not be

Code: Select all
@return {String[]}

but

Code: Select all
@return {Array<String>}
Vincent Schuurhof
Servoy
vschuurhof
 
Posts: 69
Joined: Tue Dec 14, 2010 12:00 pm

Re: String.match(regexp) JSDoc Oddity

Postby kwpsd » Thu Jun 22, 2017 6:58 pm

Well, that's interesting, because I use {String[]} in JSDoc notation everywhere with no warning or error markers (except for the String.match(regex) expression). For example:

servoy_regex_match_3.png
servoy_regex_match_3.png (46.96 KiB) Viewed 458 times


Why does JSDoc accept {String[]} notation in some cases but not in others? If {String[]} is improper notation, why is it not flagged everywhere as a warning or error? Why does String.match(regex) appear to be a special case for JSDoc? I do not mind changing to the other notation, but I would like to know the reason for it.
Kim W. Premuda
San Diego, CA USA
User avatar
kwpsd
 
Posts: 567
Joined: Sat Jul 28, 2007 6:59 pm
Location: San Diego, CA USA

Re: String.match(regexp) JSDoc Oddity

Postby pbakker » Fri Jun 23, 2017 8:19 am

String[], string[], Array<string> and Array<String> are all synonyms, so doesn't matter which one you use
pbakker
 
Posts: 2820
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands


Return to Methods

Who is online

Users browsing this forum: No registered users and 3 guests

cron