builtin.js: fix string.int method (#14564)
parent
dc30089c74
commit
db34adaec8
|
@ -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)`.
|
||||
|
|
Loading…
Reference in New Issue