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