Text Function - insert() behavior

Certified Lead Developer

I have encountered a weird behavior related to insert() function. My use case is I am trying to insert 3 new values at the top of the list. 

E.g. Initial list is {"W","X","Y","Z"} and I try the insert command like insert({"W","X","Y","Z"},{"A","B","C"},{1,2,3})

But this command doesn't yield the expected result and yields output as {"A", "W", "B", "X", "C", "Y", "Z"}

 

Again I tried like this : insert({"W","X","Y","Z"},{"A","B","C"},{1,1,1}) and output is as expected : {"A", "B", "C", "W", "X", "Y", "Z"}

 

Can someone help me understand why {1,1,1} worked but {1,2,3} didn't?

 

Thanks in advance!

  Discussion posts and replies are publicly visible

Parents
  • Hi, As per my knowledge insert function behavior as like that. Example insert({10, 20, 30, 40}, 100, {1, 2}) gives {100; 10; 100; 20; 30; 40} means first it would insert value at first postion result is {100,10,20,30,40} then later it still consider the initial input to insert the index of 2 then it becomes {100,10,100,20,30,40}. Because as we were doing insert not replace the values at positions.

    Hope it clears you.

    Regards,
    Vijay
Reply
  • Hi, As per my knowledge insert function behavior as like that. Example insert({10, 20, 30, 40}, 100, {1, 2}) gives {100; 10; 100; 20; 30; 40} means first it would insert value at first postion result is {100,10,20,30,40} then later it still consider the initial input to insert the index of 2 then it becomes {100,10,100,20,30,40}. Because as we were doing insert not replace the values at positions.

    Hope it clears you.

    Regards,
    Vijay
Children
No Data