In Robot Framework, what is the difference between a List Variable and a Scalar Variable containing a list?

我的未来我决定 提交于 2019-12-22 05:48:15

问题


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?


回答1:


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}


来源:https://stackoverflow.com/questions/25602405/in-robot-framework-what-is-the-difference-between-a-list-variable-and-a-scalar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!