Add intToString() and stringToInt() functions

This commit is contained in:
2026-01-27 12:19:26 +11:00
parent 010d155f5d
commit e3abe07f4b
2 changed files with 24 additions and 0 deletions

View File

@@ -28,6 +28,22 @@ def println(string msg) string {
return msg
}
def stringToInt(string in) int {
result = 0
ground {
stoi $in &result
}
return result
}
def intToString(int in) string {
result = ""
ground {
tostring $in &result
}
return result
}
// End Solstice stdlib
)";

8
tests/convert.sols Normal file
View File

@@ -0,0 +1,8 @@
myString = "312"
myInt = 435
myNewString = intToString(myInt)
myNewInt = stringToInt(myString)
println(myNewString)
puts myNewInt