Pardon the mess, Play My Code is in beta!

READY TO PLAY?
CLICK TO LOG IN!

sign up - lost password

split

.split( separator )

Splits this string up into parts, using the separator as the basis to split it. An array containing each of the parts is returned.

If the separator is not found then an array containing one element, the whole string, is returned. If a non-string separator is given, it is first converted into a string version, before separation. For example null will become the string "null".

// Convert a string of names into an array of names.
text = "John Brian Barry Edward Joe"
names = text.split( ' ' )

Advanced Example

/**
 * This draws the text below, a line at a time,
 * with each line indented across the screen.
 */
text = "hey
how are you?
Are you good?
That is great!
I am good too."

lines = text.split("\n")

onEachFrame() do
    
    lines.each() do |i, line|
        fillText( line, i*30, i*30 )
    end
end