mirror of
https://github.com/vlang/v.git
synced 2025-09-14 15:02:33 +03:00
builtin.js: fix string.int method (#14564)
This commit is contained in:
parent
dc30089c74
commit
db34adaec8
1 changed files with 5 additions and 1 deletions
|
@ -205,7 +205,11 @@ pub fn (s string) hash() int {
|
||||||
|
|
||||||
// int returns the value of the string as an integer `'1'.int() == 1`.
|
// int returns the value of the string as an integer `'1'.int() == 1`.
|
||||||
pub fn (s string) int() int {
|
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)`.
|
// i64 returns the value of the string as i64 `'1'.i64() == i64(1)`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue