We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cd90045 commit d40c4d5Copy full SHA for d40c4d5
2 files changed
src/main/java/com/annimon/ownlang/modules/std/StringFunctions.java
@@ -0,0 +1,20 @@
1
+package com.annimon.ownlang.modules.std;
2
+
3
+import com.annimon.ownlang.lib.Arguments;
4
+import com.annimon.ownlang.lib.NumberValue;
5
+import com.annimon.ownlang.lib.Value;
6
7
+public final class StringFunctions {
8
9
+ public static Value parseInt(Value... args) {
10
+ Arguments.checkOrOr(1, 2, args.length);
11
+ final int radix = (args.length == 2) ? args[1].asInt() : 10;
12
+ return NumberValue.of(Integer.parseInt(args[0].asString(), radix));
13
+ }
14
15
+ public static Value parseLong(Value... args) {
16
17
18
+ return NumberValue.of(Long.parseLong(args[0].asString(), radix));
19
20
+}
src/main/java/com/annimon/ownlang/modules/std/std.java
@@ -30,7 +30,6 @@ public void init() {
30
// String
31
Functions.set("sprintf", new std_sprintf());
32
Functions.set("split", new std_split());
33
- Functions.set("join", new std_join());
34
Functions.set("indexOf", new std_indexof());
35
Functions.set("lastIndexOf", new std_lastindexof());
36
Functions.set("charAt", new std_charat());
@@ -42,9 +41,12 @@ public void init() {
42
41
Functions.set("replace", new std_replace());
43
Functions.set("replaceAll", new std_replaceall());
44
Functions.set("replaceFirst", new std_replacefirst());
45
-
+ Functions.set("parseInt", StringFunctions::parseInt);
+ Functions.set("parseLong", StringFunctions::parseLong);
46
47
// Arrays and maps
48
Functions.set("newarray", new std_newarray());
49
+ Functions.set("join", new std_join());
50
Functions.set("sort", new std_sort());
51
Functions.set("arrayCombine", new std_arrayCombine());
52
Functions.set("arrayKeyExists", new std_arrayKeyExists());
0 commit comments