Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Commit 0b49148

Browse files
committed
Updated string-example to work.
1 parent 07e2a94 commit 0b49148

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

examples/string.mon

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
//
2-
// Showcase the stdlib string-functions
2+
// Showcase some of our string-functions.
33
//
44

55

6-
puts( string.toupper( "Steve Kemp" ), "\n" )
7-
puts( string.tolower( "Steve Kemp" ), "\n" )
8-
puts( string.trim( " This should have no leading/trailing spaces. \t" ), "\n" )
6+
let input = " Steve Kemp ";
97

10-
let str = "The quick brown 狐 jumped over the lazy 犬";
11-
puts( "String : " + str + "\n" );
12-
puts( "Reversed: " + string.reverse(str) + "\n" );
8+
puts( "Input: '", input, "'\n" );
9+
10+
// Case-conversion
11+
puts( "Upper: '", input.toupper(), "'\n");
12+
puts( "Lower: '", input.tolower(), "'\n");
1313

14+
// Removing whitespace
15+
puts( "ltrim: '", input.ltrim(), "'\n");
16+
puts( "rtrim: '", input.rtrim(), "'\n");
17+
puts( "trim: '", input.trim(), "'\n");
18+
19+
// Reversing
20+
let str = "The quick brown 狐 jumped over the lazy 犬";
21+
puts( "String : '" + str + "'\n" );
22+
puts( "Reversed: '" + str.reverse() + "'\n" );
1423

15-
puts( "We allow escaping quotes, like so: \"\n" );
24+
// Escapes are good.
25+
puts( "We also allow escaping quotes, like so: \"\n" );

0 commit comments

Comments
 (0)