reset

..  reset(s)

Reset a stream ``s`` to a previously marked position, and remove the mark.
Returns the previously marked position.
Throws an error if the stream is not marked.

See also :func:`mark`, :func:`unmark`, :func:`ismarked`

Examples

In the Julia programming language, the function reset(s) is used to reset a stream s to a previously marked position and remove the mark. It returns the previously marked position. If the stream is not marked, it throws an error.

Reset a stream to a previously marked position:

julia> s = "Hello, World!";
julia> mark(s, 6);
julia> reset(s)
6

This example sets a mark at index 6 in the string s and then resets the stream to that marked position.

Handling an error when the stream is not marked:

julia> s = "Hello";
julia> reset(s)
ERROR: ArgumentError: stream is not marked

In this example, an error is thrown because the stream s is not marked before attempting to reset it.

Related functions:

  • mark(s): Marks the current position in the stream s.
  • unmark(s): Removes the mark from the stream s.
  • ismarked(s): Checks if the stream s is marked.

Note: The reset function is commonly used in conjunction with the mark, unmark, and ismarked functions to manage stream positions.

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: