In Robot Framework, we can assign a list to a Scalar Variable or to a List Variable, as shown below:
| @{list} = | Create List | a | b | c |
| ${scalar} = | Create List | a | b | c |
What is the difference between a List Variable and a Scalar Variable containing a list?
There are three types of variables supported in robot framework − scalar, list and dictionary.
Scalar Variable in Robot Framework A Scalar variable holds a single value at a time, and it is a single component that assumes the range of numbers. The Scalar variable is used to store the Strings, Objects, List, etc.. The syntax for the scalar variable is ${variablename}
In case of the assignment shown in your question, there is no difference. If you log each of those you'll get the exact same output.
Note: this functionality was introduced in version 2.8 (see Using scalar variables as lists in Robot Framework User's Guide).
The difference comes when you use the values. When you use the @
symbol to reference a list, each of the elements in the list becomes a cell. In the following example, the following three lines give identical results:
| | A keyword that expects three arguments | a | b | c
| | A keyword that expects three arguments | @{list}
| | A keyword that expects three arguments | @{scalar}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With