iostream.blob.constructor
Creates a blob of the given size (default 0)
Parameters
size | int | number of bytes to allocate optional |
Errors
Throws cannot create blob with negative size when size is negative.
Notes
size defaults to 0, which makes an empty blob rather than failing; writing to it later grows it, as described on writen.
Example
from "iostream" import blob
let empty = blob() // size defaults to 0
println("empty.len() =", empty.len())
let b = blob(3) // new bytes are zero-filled
println("b[0], b[1], b[2] =", $"{b[0]},{b[1]},{b[2]}")
try {
blob(-1)
} catch (e) {
println("blob(-1) throws:", e)
}Output:
empty.len() = 0
b[0], b[1], b[2] = 0,0,0
blob(-1) throws: cannot create blob with negative sizeSee also
resize | Resizes the blob to the given size |
len | Returns the stream length |
tell | Returns the current stream position |
| blob | class index |