Problem (?) with string string.split()?

Problem (?) with string string.split()?

guiroehe
Advocate Advocate
37 Views
1 Reply
Message 1 of 2

Problem (?) with string string.split()?

guiroehe
Advocate
Advocate

[ FlexSim 25.0.1 ]

Hello, any reasons why this happens?

1736785177166.pngShould not this command return Array[0]? I.e., why is the length 1?

0 Likes
Accepted solutions (1)
38 Views
1 Reply
Reply (1)
Message 2 of 2

emily_hardySTLSK
Autodesk
Autodesk
Accepted solution

If you split a string that doesn't contained the passed in delimiter it will return the original string. In your example, the empty string is returned so the array has 1 entry (an empty string). Any string that you split that doesn't contain the delimiter will have the same result:

string("Test").split(",") returns Array[1]: [Test]