Product Site

5.1.7.51. compare

Returns 0 if the argument string is identical to the receiving string. Otherwise, returns the position of the first character that does not match. The shorter string is padded on the right with pad if necessary. The default pad character is a blank.
Example 5.89. String class — compare method
Say "abc"~compare("abc")         -->    0
Say "abc"~compare("ak")          -->    2
Say "ab "~compare("ab")          -->    0
Say "ab "~compare("ab"," ")      -->    0
Say "ab "~compare("ab","x")      -->    3
Say "ab-- "~compare("ab","-")    -->    5