For your second question, either you use 'case objects' or [plain when 
blocks](https://glot.io/snippets/eo08zs4n85):
    
    
    template chain(iter1, iter2: typed, body: untyped) =
      block:
        for v {.inject.} in iter1():
          body
        for v {.inject.} in iter2():
          body
    
    iterator thing1: string =
      yield "A"
      yield "B"
    
    iterator thing2: int =
      yield 1
      yield 2
    
    chain(thing1,thing2):
      when v is string:
        echo("String: ", v)
      elif v is int:
        echo(v + 5)
    

Reply via email to