mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
replace to_i() with int() everywhere
This commit is contained in:
@@ -138,16 +138,12 @@ pub fn (s string) replace(rep, with string) string {
|
||||
return tos(b, new_len)
|
||||
}
|
||||
|
||||
fn (s string) to_i() int {
|
||||
fn (s string) int() int {
|
||||
return C.atoi(s.str)
|
||||
}
|
||||
|
||||
fn (s string) int() int {
|
||||
return s.to_i()
|
||||
}
|
||||
|
||||
fn (s string) i32() int {
|
||||
return s.to_i()
|
||||
fn (s string) f32() f32 {
|
||||
return C.atof(s.str)
|
||||
}
|
||||
|
||||
// ==
|
||||
|
||||
@@ -251,16 +251,16 @@ fn test_arr_contains() {
|
||||
|
||||
fn test_to_num() {
|
||||
s := '7'
|
||||
assert s.to_i() == 7
|
||||
assert s.int() == 7
|
||||
f := '71.5 hasdf'
|
||||
assert f.to_float() == 71.5
|
||||
assert f.f32() == 71.5
|
||||
b := 1.52345
|
||||
mut a := '${b:.03f}'
|
||||
assert a == '1.523'
|
||||
num := 7
|
||||
a = '${num:03d}'
|
||||
vals := ['9']
|
||||
assert vals[0].to_i() == 9
|
||||
assert vals[0].int() == 9
|
||||
}
|
||||
|
||||
fn test_hash() {
|
||||
@@ -289,4 +289,4 @@ fn test_all_after() {
|
||||
s := 'fn hello'
|
||||
q := s.all_after('fn ')
|
||||
assert q == 'hello'
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user