forked from solstice/solstice
Add intToString() and stringToInt() functions
This commit is contained in:
@@ -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
8
tests/convert.sols
Normal file
@@ -0,0 +1,8 @@
|
||||
myString = "312"
|
||||
myInt = 435
|
||||
|
||||
myNewString = intToString(myInt)
|
||||
myNewInt = stringToInt(myString)
|
||||
|
||||
println(myNewString)
|
||||
puts myNewInt
|
||||
Reference in New Issue
Block a user