I have a scenario as below: -
我有一个设想如下:
Scenario: Reassign variable
* def name = "Amod"
* print "Hello " + name
* name = "Animesh"
* print "Hello " + name
It gives error below-
它给出以下错误-
* name = "Animesh"
no step-definition method match found for: name = "Animesh"
To make it work I need to use "def" keyword again. A variable is meant to be declared once and reused & reassigned whenever required. Is it memory efficient to define it every time?
要使其正常工作,我需要再次使用“def”关键字。变量应该声明一次,并在需要时重新使用和重新分配。每次定义它是否都会节省内存?
更多回答
优秀答案推荐
Karate allows you to "overwrite" a variable using def
. You will see a warning in the console. We don't see any memory issues.
Karate允许你使用def“覆盖”一个变量。你会在控制台看到一个警告。我们没发现任何记忆问题。
更多回答
我是一名优秀的程序员,十分优秀!