do you intent to use option[Cell] at all? Run I can also use filterIt. Direction = random.sample( filterIt( [(if j+1 > 0 and j+1 < Size: some(Cell(x:j+1, y:i)) else: none(Cell)), (if i+1 > 0 and i+1 < Size: some(Cell(x:j, y:i+1)) else: none(Cell))], it.isSome) ) Run
and I intent to use it