lundi 1 mars 2021

what is the variable scope in if statement in karate tfw?

Can you help me to understand the scope of the variables in if statement?

 * def a = "a"
 * if ( 1 == 1 ) a = "b"
 * print "a--",a

 * def str =
      """
      <tag>#(a)</tag>
      """
 * print "str--",str
output : 
[print] a-- a
[print] str-- <tag>b</tag>

edit: When i use karate.set('a',"b") instead of just a = "b" Then the output looks correct.

[print] a-- b
[print] str-- <tag>b</tag>

Aucun commentaire:

Enregistrer un commentaire