builtin.js: fix string.int method (#14564)

master
playX 2022-05-31 08:52:11 +00:00 committed by GitHub
parent dc30089c74
commit db34adaec8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -205,7 +205,11 @@ pub fn (s string) hash() int {
// int returns the value of the string as an integer `'1'.int() == 1`.
pub fn (s string) int() int {
return int(JS.parseInt(s.str))
res := int(0)
#if (typeof(s) == "string") { res.val = parseInt(s) }
#else { res.val = parseInt(s.str) }
return res
}
// i64 returns the value of the string as i64 `'1'.i64() == i64(1)`.