mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
vlib: refactor empty string checks to use s == ''
or s != ''
, instead of s.len == 0
(#21300)
This commit is contained in:
parent
46be635072
commit
8aa9314a99
55 changed files with 95 additions and 96 deletions
|
@ -47,7 +47,7 @@ fn get_bet_nbr() int {
|
|||
println('Reminder: odd numbers are red and even are black.')
|
||||
println('Type the number you want to bet on (between 0 and 49):')
|
||||
line := os.get_line().trim_space()
|
||||
if line.len < 1 {
|
||||
if line == '' {
|
||||
println('error: empty line.')
|
||||
continue
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ fn get_bet(money int) int {
|
|||
for bet <= 0 || bet > money {
|
||||
println('You have ${money} V. Type in the amount of your bet:')
|
||||
line := os.get_line().trim_space()
|
||||
if line.len < 1 {
|
||||
if line == '' {
|
||||
println('error: empty line.')
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ fn (item_list Item_list) get_file_path() string {
|
|||
if item_list.lst.len <= 0 || item_list.n_item <= 0 {
|
||||
return ''
|
||||
}
|
||||
if item_list.lst[item_list.item_index].path.len > 0 {
|
||||
if item_list.lst[item_list.item_index].path != '' {
|
||||
return '${item_list.lst[item_list.item_index].path}${item_list.path_sep}${item_list.lst[item_list.item_index].name}'
|
||||
}
|
||||
return item_list.lst[item_list.item_index].name
|
||||
|
|
|
@ -296,7 +296,7 @@ pub fn load_image(mut app App) {
|
|||
}
|
||||
|
||||
file_path := app.item_list.get_file_path()
|
||||
if file_path.len > 0 {
|
||||
if file_path != '' {
|
||||
// println("${app.item_list.lst[app.item_list.item_index]} $file_path ${app.item_list.lst.len}")
|
||||
app.texture, app.sampler, app.img_w, app.img_h = app.load_texture_from_file(file_path)
|
||||
app.img_ratio = f32(app.img_w) / f32(app.img_h)
|
||||
|
|
|
@ -50,7 +50,7 @@ pub fn (app &App) create_todo(mut ctx Context, name string) vweb.Result {
|
|||
// we could also access the name field by doing `name := ctx.form['name']`
|
||||
|
||||
// validate input field
|
||||
if name.len == 0 {
|
||||
if name == '' {
|
||||
// set a form error
|
||||
ctx.form_error = 'You must fill in all the fields!'
|
||||
// send a HTTP 400 response code indicating that the form fields are incorrect
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue