aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/old/vlib/v/fmt/tests/or_keep.vv
blob: a1d1f65d6b063d2433bbdd247f4b7b106edfb081 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
fn main() {
	empty_or_block() or {}
	empty_or_block() or {
	}
}

fn fn_with_or() int {
	fn_with_optional() or { return 10 }
	return 20
}

fn (f Foo) method_with_or() int {
	f.fn_with_optional() or { return 10 }
	return 20
}

fn unwrapped_single_line_if() {
	namefound := publisher.name_fix_check(name_to_find, state.site.id, ispage) or {
		if err.contains('Could not find') {
			state.error('cannot find link: $name_to_find')
		} else {
			state.error('cannot find link: $name_to_find\n$err')
		}
		println('Another stmt')
	}
}

fn or_with_one_multi_line_stmt() {
	b := or_func() or {
		MyStruct{
			val: 'xyz'
		}
	}
}

fn channel_pop() {
	var_init := <-ch or { -1.25 }
	var_assign = <-ch or { -2.5 }
	arr_push << <-ch or { -3.75 }
}