| 1 | fn main() { |
| 2 | empty_or_block() or {} |
| 3 | empty_or_block() or { |
| 4 | } |
| 5 | } |
| 6 | |
| 7 | fn fn_with_or() int { |
| 8 | fn_with_option() or { return 10 } |
| 9 | return 20 |
| 10 | } |
| 11 | |
| 12 | fn (f Foo) method_with_or() int { |
| 13 | f.fn_with_option() or { return 10 } |
| 14 | return 20 |
| 15 | } |
| 16 | |
| 17 | fn unwrapped_single_line_if() { |
| 18 | namefound := publisher.name_fix_check(name_to_find, state.site.id, ispage) or { |
| 19 | if err.contains('Could not find') { |
| 20 | state.error('cannot find link: ${name_to_find}') |
| 21 | } else { |
| 22 | state.error('cannot find link: ${name_to_find}\n${err}') |
| 23 | } |
| 24 | println('Another stmt') |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | fn or_with_one_multi_line_stmt() { |
| 29 | b := or_func() or { |
| 30 | MyStruct{ |
| 31 | val: 'xyz' |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | fn channel_pop() { |
| 37 | var_init := <-ch or { -1.25 } |
| 38 | var_assign = <-ch or { -2.5 } |
| 39 | arr_push << <-ch or { -3.75 } |
| 40 | } |
| 41 | |