Quirrel4.41.0

iostream.blob.len

Method of blob, from module "iostream"
instance.len(): int

Returns the stream length

Return value

See iostream.stream.len for the generic contract.

Notes

This is the length set by the constructor or resize, or grown implicitly by a write past the end (see writen). It does not depend on the cursor; use tell for that.

Example

examples/iostream/blob/len.nut
from "iostream" import blob

let b = blob(4)
println("b.len() at start =", b.len())
b.seek(0, 'e')
b.writen(1, 'b')   // writing past the end grows len
println("b.len() after writen past end =", b.len())

b.seek(0)
println("b.len() after seek(0) =", b.len())  // seeking never changes len, only tell
Output:
b.len() at start = 4
b.len() after writen past end = 5
b.len() after seek(0) = 5

See also

lenReturns the stream length
tellReturns the current stream position
resizeResizes the blob to the given size
blobclass index