Download OPL Language Reference Manual
Transcript
String operators Provides a reference of string operators. Table 29. String operators Syntax Effect string1 + string2 Returns a string containing the concatenation of string1 and string2. Examples:"Hello," + " world" –> "Hello, world" When the operator + is used to add a string to a nonstring value, the nonstring value is first converted to a string. Examples: "Your age is " + 23 –> "Your age is 23" 23 + " is your age" –> "23 is your age" string1 == string2 string1 != string2 The operator == returns the Boolean true if string1 and string2 are identical, and false otherwise. Two strings are identical if they have the same length and contain the same sequence of characters. The operator != is the converse of ==. Examples: "a string" == "a string" –> true "a string" == "another string" –> false "a string" == "A STRING" –> false "a string" != "a string" –> false "a string" != "another string" –> true When the operators == and != are used to compare a string with a number, the string is first converted to a number and the two numbers are compared numerically. Examples: "12" == "+12" –> false 12 == "+12" –> true 116 OPL Language Reference Manual