Expand

in

  1. in for, iterate over a specified list, map or another container:

    for $host in [1, 2, 3] {
        print ($number ** 2)
    }
  2. a binary operator that checks an element (left argument) exists in a container (right argument).

    It has the same priority as comparison operations like <= or > and higher priority than logical operations and or or. All other operations are higher priority.

    check that item exists in a list
    $list := [1, 2, [4], 6]
    
    put (1   in $list) # true
    put ([4] in $list) # true
    put (4   in $list) # false
    check key exists in a dictionary
    $languages := {
        python: null,
        rust:   null,
        go:     null,
    }
    $hasC  := "c"  in $map # false
    $hasGo := "go" in $map # true
    check if $age is a teenage-range of 13..18 inclusive.
    if $age in (range 13 19) {
        print "$age yo is a teenager"
    }