Version 1 (modified by Chuck, 15 years ago) |
---|
StringBuilder
Cobra strings are immutable. To create something like a mutable string, use StringBuilder:
def visitMessage(url) as String sb = StringBuilder() sb.appendLine('Hello [.name],') sb.appendLine('Please visit [ur].') return sb.toString
If you would like to use newlines in your code, try CobraCore.newLine which returns the newline specific to the current platform such as '\n' or '\r\n':
def visitMessage(url) as String nl = CobraCore.newLine sb = StringBuilder() sb.append('Hello [.name],[nl]') sb.append('Please visit [ur].[nl]') return sb.toString
For more information on the StringBuilder class, see Google(C# StringBuilder)
See also: LibraryTopics