| 1 | fn print_true(i int) bool { |
| 2 | println(i) |
| 3 | return true |
| 4 | } |
| 5 | |
| 6 | const other_list = [3, 4] |
| 7 | |
| 8 | fn main() { |
| 9 | list := [1, 2, 3] |
| 10 | index := 3 |
| 11 | if index < list.len && list[index] == 3 { |
| 12 | println('Index is within bounds and value is 3') |
| 13 | } else { |
| 14 | println('Index is out of bounds or value is not 3') |
| 15 | } |
| 16 | if index < list.len && print_true(list[index]) { |
| 17 | println('Index is within bounds') |
| 18 | } else { |
| 19 | println('Index is out of bounds') |
| 20 | } |
| 21 | if index < list.len && other_list.contains(list[index]) { |
| 22 | println('Index is within bounds and value is in other_list') |
| 23 | } else { |
| 24 | println('Index is out of bounds or value is not in other_list') |
| 25 | } |
| 26 | if index < list.len && (other_list.contains(list[index]) || other_list.contains(list[index])) { |
| 27 | println('Index is within bounds and value is in other_list') |
| 28 | } else { |
| 29 | println('Index is out of bounds or value is not in other_list') |
| 30 | } |
| 31 | } |
| 32 | |