Ankit Desai
Ankit Desai

Reputation: 81

Using karate.set to change value of an array

I want to change the values present in an array using karate.set as i am using it in if condition my code is:

> * def name = ["ankit"]
> * def value = 2
> * eval if ( value == 2) karate.set('name', 'ANKIT_DESAI')

but the value of name is not changing

Upvotes: 1

Views: 662

Answers (1)

Babu Sekaran
Babu Sekaran

Reputation: 4239

Assume that as a list and modify value based on index

* def name = ["ankit"]
* def value = 2
* eval if ( value == 2) name[0] = "ANKIT_DESAI" 

Upvotes: 2

Related Questions