JanetDocsSourcePlaygroundTutorialsI'm Feeling luckyCommunityGitHub sign in

buffer/slice

core-api


    cfunction
    src/core/buffer.c on line 532, column 1

    (buffer/slice bytes &opt start end)

    Same as `string/slice`, but returns a buffer.


1 exampleSign in to add an example
Loading...
Example usage


janet:1:> (def buf @"ABCDE")
@"ABCDE"
janet:2:> (buffer/slice 0)
error: bad slot #0, expected string|symbol|keyword|buffer, got 0
  in buffer/slice
  in _thunk [repl] (tailcall) on line 2, column 1
janet:3:> (buffer/slice buf 0)
@"ABCDE"
janet:4:> (buffer/slice buf 0 1)
@"A"
janet:5:> (buffer/slice buf 0 -1)
@"ABCDE"
janet:6:> (buffer/slice buf 1 3)
@"BC"
roobiePlayground