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

playX 2022-05-31 08:52:11 +00:00 committed by Chewing_Bever
parent eb688d7fa1
commit 9e038d1a64
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
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)`.