| 1 | fn fn_with_if_else() { |
| 2 | if true { |
| 3 | a = 10 |
| 4 | a++ |
| 5 | } else { |
| 6 | println('false') |
| 7 | } |
| 8 | } |
| 9 | |
| 10 | fn fn_with_if_else_oneline() { |
| 11 | _ := if true { 1 } else { 2 } |
| 12 | } |
| 13 | |
| 14 | fn short_if_stmts(a int) { |
| 15 | if a <= 10 { println('vfmt_0') } |
| 16 | if a > 10 { println('vfmt_1') } |
| 17 | if this_is_a_very_long_condition_name && this_is_another_really_long_condition_name |
| 18 | && this_pushes_past_the_limit { |
| 19 | println('wrapped') |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | fn dynamic_where_expr(name_filter string, min_age int, status_filter string) { |
| 24 | dynamic_where := { |
| 25 | if name_filter != '' { name == name_filter }, |
| 26 | if min_age > 0 { age >= min_age }, |
| 27 | if status_filter != '' { status == status_filter } |
| 28 | } |
| 29 | _ = dynamic_where |
| 30 | } |
| 31 | |
| 32 | fn dynamic_where_expr_comments(mobile ?string) { |
| 33 | dynamic_where := { |
| 34 | // mobile update |
| 35 | if m := mobile { |
| 36 | phone == m, |
| 37 | // nested comment |
| 38 | }, |
| 39 | // name == name_dyn |
| 40 | } |
| 41 | _ = dynamic_where |
| 42 | } |
| 43 | |