How do I swap the first two bytes of the openArray in the following code?

# t.nim(5, 35) Error: expression has no address
    
    
    import strutils
    import endians
    
    proc num(buffer: openArray[uint8]): uint16 =
      swapEndian16(addr(result), addr(buffer))
    
    var buffer = [0x01'u8, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef]
    var num16 = num(buffer)
    echo toHex(num16)
    

Reply via email to