| 1 | == StringBuilder == |
| 2 | |
| 3 | Cobra strings are immutable. To create something like a mutable string, use StringBuilder: |
| 4 | {{{ |
| 5 | #!python |
| 6 | def visitMessage(url) as String |
| 7 | sb = StringBuilder() |
| 8 | sb.appendLine('Hello [.name],') |
| 9 | sb.appendLine('Please visit [ur].') |
| 10 | return sb.toString |
| 11 | }}} |
| 12 | |
| 13 | 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': |
| 14 | {{{ |
| 15 | #!python |
| 16 | def visitMessage(url) as String |
| 17 | nl = CobraCore.newLine |
| 18 | sb = StringBuilder() |
| 19 | sb.append('Hello [.name],[nl]') |
| 20 | sb.append('Please visit [ur].[nl]') |
| 21 | return sb.toString |
| 22 | }}} |
| 23 | |
| 24 | For more information on the StringBuilder class, see [http://www.google.com/search?hl=en&q=C%23+stringbuilder Google(C# StringBuilder)] |
| 25 | |
| 26 | See also: LibraryTopics |