SPLK-1002 · Question #80
What is the correct way to name a macro with two arguments?
The correct answer is D. us_sales(2). In Splunk, a macro that accepts arguments is named using the format macroname(N), where N is the integer count of arguments the macro expects.
Question
What is the correct way to name a macro with two arguments?
Options
- Aus_sales2
- Bus_sales(1,2)
- Cus_sale,2
- Dus_sales(2)
How the community answered
(63 responses)- A3% (2)
- B2% (1)
- C6% (4)
- D89% (56)
Why each option
In Splunk, a macro that accepts arguments is named using the format macroname(N), where N is the integer count of arguments the macro expects.
us_sales2 is treated as a zero-argument macro named literally 'us_sales2'; appending the number to the name without parentheses does not define argument count in Splunk's macro naming convention.
us_sales(1,2) is not valid macro naming syntax; the parentheses must contain only the integer count of arguments, not a list of argument values or names.
us_sale,2 is syntactically invalid for a macro name; commas are not used in macro naming and this form would not be recognized by the Splunk macro system.
us_sales(2) is the correct naming convention for a Splunk macro with two arguments; the argument count in parentheses is part of the macro's unique identifier, so us_sales(2) is a distinct macro from us_sales or us_sales(1).
Concept tested: Splunk macro naming convention with arguments
Source: https://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Definesearchmacros
Topics
Community Discussion
No community discussion yet for this question.