Just getting into Nim and coming from non-statically typed languages :) Thanks 
in advance for any advice!

I wanted to pack some **proc** into an array (so they're indexable by an 
integer) and this is what I came up with which did actually work. I would like 
to do it the proper "Nim" way though.
    
    
    type
      Action = proc(text: string)
    
    let a_echo: Action = proc (text: string) =
      echo text
    
    var action = 0x60
    var actions: array[0x60..0x69, Action]
    for i in actions.low..actions.high:
      actions[i] = a_echo
    
    
    Run

I did look at these for inspiration already: 
<https://forum.nim-lang.org/t/2895>, <https://forum.nim-lang.org/t/2050>

Reply via email to