From 37af25315167a74280db82179bded2b63e3d000f Mon Sep 17 00:00:00 2001 From: Flipez Date: Tue, 1 Nov 2022 18:25:40 +0100 Subject: [PATCH 1/3] fix args for string.find and string.count Signed-off-by: Flipez --- object/string.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/object/string.go b/object/string.go index ff83e8a..99abca0 100644 --- a/object/string.go +++ b/object/string.go @@ -27,11 +27,9 @@ func init() { ๐Ÿš€ > "test".count("f") => 0 ๐Ÿš€ > "test1".count("1") -=> 1 -๐Ÿš€ > "test1".count(1) => 1`, ArgPattern: Args( - Arg(STRING_OBJ, INTEGER_OBJ), // first argument can be string or int + Arg(STRING_OBJ), ), ReturnPattern: Args( Arg(INTEGER_OBJ), @@ -51,7 +49,7 @@ func init() { ๐Ÿš€ > "test".find("f") => -1`, ArgPattern: Args( - Arg(STRING_OBJ, INTEGER_OBJ), // first argument can be string or int + Arg(STRING_OBJ), ), ReturnPattern: Args( Arg(INTEGER_OBJ), @@ -73,7 +71,7 @@ func init() { ๐Ÿš€ ยป "test%s".format("test") ยป "testtest"`, ArgPattern: Args( - OverloadArg(STRING_OBJ, INTEGER_OBJ, FLOAT_OBJ, BOOLEAN_OBJ), // first argument can be string or int + OverloadArg(STRING_OBJ, INTEGER_OBJ, FLOAT_OBJ, BOOLEAN_OBJ), ), ReturnPattern: Args( Arg(STRING_OBJ), From b5d7c282de46fa295b6ae3d92cb8226f15ed0f44 Mon Sep 17 00:00:00 2001 From: Flipez Date: Tue, 1 Nov 2022 18:28:35 +0100 Subject: [PATCH 2/3] fix docs Signed-off-by: Flipez --- docs/docs/literals/string.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/docs/literals/string.md b/docs/docs/literals/string.md index 5d2e466..7f1473c 100644 --- a/docs/docs/literals/string.md +++ b/docs/docs/literals/string.md @@ -44,7 +44,7 @@ puts(s) ## Literal Specific Methods -### count(STRING|INTEGER) +### count(STRING) > Returns `INTEGER` Counts how often a given string or integer occurs in the string. Converts given integers to strings automatically. @@ -57,8 +57,6 @@ Counts how often a given string or integer occurs in the string. Converts given => 0 ๐Ÿš€ > "test1".count("1") => 1 -๐Ÿš€ > "test1".count(1) -=> 1 ``` @@ -91,7 +89,7 @@ Replaces all upcase characters with lowercase counterparts. ``` -### find(STRING|INTEGER) +### find(STRING) > Returns `INTEGER` Returns the character index of a given string if found. Otherwise returns `-1` From 5eb1a2c3829e7dd82d01feb95c68394a0873a023 Mon Sep 17 00:00:00 2001 From: Flipez Date: Tue, 1 Nov 2022 18:34:07 +0100 Subject: [PATCH 3/3] fix docs Signed-off-by: Flipez --- docs/docs/literals/string.md | 2 +- object/string.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/literals/string.md b/docs/docs/literals/string.md index 7f1473c..5b1abbe 100644 --- a/docs/docs/literals/string.md +++ b/docs/docs/literals/string.md @@ -47,7 +47,7 @@ puts(s) ### count(STRING) > Returns `INTEGER` -Counts how often a given string or integer occurs in the string. Converts given integers to strings automatically. +Counts how often a given substring occurs in the string. ```js diff --git a/object/string.go b/object/string.go index 99abca0..526321c 100644 --- a/object/string.go +++ b/object/string.go @@ -21,7 +21,7 @@ func init() { objectMethods[STRING_OBJ] = map[string]ObjectMethod{ "count": ObjectMethod{ Layout: MethodLayout{ - Description: "Counts how often a given string or integer occurs in the string. Converts given integers to strings automatically.", + Description: "Counts how often a given substring occurs in the string.", Example: `๐Ÿš€ > "test".count("t") => 2 ๐Ÿš€ > "test".count("f")