Discord
Login
Community
DARK THEME

How use i string.split?

How do I use it to make it work? I have a variable and would like to split it into individual words.

It is a bit unclear inside the documentation, but it refers to the string itself, not an object called string.

Example 1:

s = "Hello World!"
splitted = s.split(" ")
// -> Results in ["Hello","World!"]

Example 2:

splitted = "Hello World!".split(" ")
// -> Results in the same as Example 1

The documentation is really confusing there, so no hard feelings. The same principle can be pretty much applied to the other types too.

Good luck with your game!

Thank you very much

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community