position

position(s)

Get the current position of a stream.

Examples

In the Julia programming language, the function position(s) is used to get the current position of a stream s. It returns the position as an integer.

julia> io = IOBuffer("Hello, world!")
IOBuffer(data=UInt8[...], readable=true, writable=false, seekable=true, append=false, size=13, maxsize=Inf, ptr=1, mark=-1)

julia> position(io)
1

This example demonstrates how to get the current position of a stream io. The initial position is at index 1.

Common mistake example:

julia> str = "Hello, world!"
julia> position(str)
ERROR: MethodError: no method matching position(::String)

In this example, the position function is called with a String object instead of a stream. It's important to ensure that the function is used with a stream object for it to work correctly.

See Also

deserialize, eachline, eof, fd, flush, IOBuffer, ismarked, isopen, isreadonly, mark, nb_available, open, pipeline, position, read, read!, readavailable, readbytes, readbytes!, readline, redirect_stderr, redirect_stdin, reset, seek, seekend, seekstart, serialize, skip, skipchars, TextDisplay, unmark, write, writemime,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: