Buffer iteration iterable

Buffers are iterable through the Luart helper function each(), returning the next byte in the Buffer with each loop iteration. Each iteration returns the byte value as a number.

Example

local console = require "console" console.write("\nEnter your name : ") local buff = sys.Buffer(console.readln()) console.write("\nLet me show you its binary representation... ") for byte in each(buff) do local hex = string.format("%X", byte) console.write("["..hex.."] ") end console.write("\n")