Skip to content

Commit 637cac2

Browse files
committed
update readme; added comments
1 parent e1ee590 commit 637cac2

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ if RuneIsAwesome {
906906

907907
### typeof
908908
- **Syntax**: `typeof(<arg>)`
909-
- **Description**: Returns the type name as a string of the given argument. Possible types are: `int`, `float`, `string`, `bool` and`unknown`.
909+
- **Description**: Returns the type name as string of the given argument. Possible types are: `int`, `float`, `string`, `bool`, `array`, `table` and `unknown`.
910910
- **Example**: `typeof(10) # returns "int"`
911911

912912
### append

builtins.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ func builtin_Contains(args ...interface{}) interface{} {
277277
return strings.Contains(str, substr)
278278
}
279279

280+
// Returns the type name as string of the given argument.
280281
func builtin_TypeOf(args ...interface{}) interface{} {
281282
if len(args) != 1 {
282283
return fmt.Errorf("typeof requires exactly 1 argument")
@@ -294,12 +295,13 @@ func builtin_TypeOf(args ...interface{}) interface{} {
294295
case []interface{}:
295296
return "array"
296297
case map[string]interface{}:
297-
return "map"
298+
return "table"
298299
default:
299300
return "unknown"
300301
}
301302
}
302303

304+
// Appends the given value to the given array, table or string. Returns the new array, table or string.
303305
func builtin_append(args ...interface{}) interface{} {
304306
if len(args) < 2 {
305307
return fmt.Errorf("append requires exactly 2 arguments for array/string or 3 arguments for map")
@@ -326,6 +328,7 @@ func builtin_append(args ...interface{}) interface{} {
326328
}
327329
}
328330

331+
// Removed the given index from the given array, table or string. Returns the new array, table or string.
329332
func builtin_remove(args ...interface{}) interface{} {
330333
if len(args) != 2 {
331334
return fmt.Errorf("remove requires exactly 2 arguments")
@@ -366,6 +369,7 @@ func builtin_remove(args ...interface{}) interface{} {
366369
}
367370
}
368371

372+
// Returns true if the given table has the given key, otherwise false.
369373
func builtin_hasKey(args ...interface{}) interface{} {
370374
if len(args) != 2 {
371375
return fmt.Errorf("hasKey requires exactly 2 arguments")
@@ -387,6 +391,7 @@ func builtin_hasKey(args ...interface{}) interface{} {
387391
return exists
388392
}
389393

394+
// Returns a slice of the given array, table, or string from the start index to the end index.
390395
func builtin_slice(args ...interface{}) interface{} {
391396
if len(args) != 3 {
392397
return fmt.Errorf("slice requires exactly 3 arguments")
@@ -431,6 +436,7 @@ func builtin_slice(args ...interface{}) interface{} {
431436
}
432437
}
433438

439+
// Returns a slice of the given array, table, or string from the start to the given end index.
434440
func builtin_sliceLeft(args ...interface{}) interface{} {
435441
if len(args) != 2 {
436442
return fmt.Errorf("sliceFirst requires exactly 2 arguments")
@@ -470,6 +476,7 @@ func builtin_sliceLeft(args ...interface{}) interface{} {
470476
}
471477
}
472478

479+
// Returns a slice of the given array, table, or string from the given start index to the end.
473480
func builtin_sliceRight(args ...interface{}) interface{} {
474481
if len(args) != 2 {
475482
return fmt.Errorf("sliceLast requires exactly 2 arguments")
@@ -509,6 +516,7 @@ func builtin_sliceRight(args ...interface{}) interface{} {
509516
}
510517
}
511518

519+
// Returns the lenght of the given array, table or string.
512520
func builtin_Len(args ...interface{}) interface{} {
513521
if len(args) != 1 {
514522
return fmt.Errorf("len requires exactly 1 argument")
@@ -526,6 +534,7 @@ func builtin_Len(args ...interface{}) interface{} {
526534
}
527535
}
528536

537+
// Returns a deep copy of the given array or table.
529538
func builtin_New(args ...interface{}) interface{} {
530539
if len(args) != 1 {
531540
return fmt.Errorf("new requires exactly 1 argument")
@@ -600,7 +609,6 @@ func formatMap(m map[string]interface{}) string {
600609
sb.WriteString("}")
601610
return sb.String()
602611

603-
604612
}
605613

606614
func deepCopyArray(arr []interface{}) []interface{} {

0 commit comments

Comments
 (0)