MyTetra Share
Делитесь знаниями!
Функция с переменным числом аргументов
Время создания: 22.04.2017 19:09
Раздел: AutoHotkey - Functions
Запись: xintrea/mytetra_db_mcold/master/base/1492877346yieuf6hsrc/text.html на raw.githubusercontent.com

Join(sep, params*) {

for index,param in params

str .= param . sep

return SubStr(str, 1, -StrLen(sep))

}

MsgBox % Join("`n", "one", "two", "three")


substrings := ["one", "two", "three"]

MsgBox % Join("`n", substrings*)

Notes:

  • Numbering of parameters within the source array begins at 1.
  • Optional parameters may be entirely omitted from the array.
  • The array of parameters may contain named items when calling a user-defined function; in any other case, named items are not supported.
  • The target function may also be variadic, in which case named items are copied even if they have no corresponding formal parameter.
  • This syntax can also be used when calling methods or retrieving properties of objects; for example, Object.Property[Params*]. In v1.1.12+, it can also be used for setting properties.

Known limitations:

  • Only the right-most parameter can be expanded this way. For example, Func(x, y*) is supported but Func(x*, y) is not.
  • There must not be any non-whitespace characters between the asterisk (*) and the symbol which ends the parameter list.

Ограничения:

- итерация массива начинается с 1-цы

- переменное число аргументов может быть только последним параметром объявления функции

 
MyTetra Share v.0.59
Яндекс индекс цитирования