# bin/set-bytes
Return a copy of `$bytes` with the bytes of `$data` overlaid at `offset`.
The copy has the same length as the original — this is an overlay, not an
insert. Byte strings are immutable, so the original is unchanged.
## Syntax
[bin/set-bytes $bytes $offset $data]
## Parameters
- `$bytes` — byte string to copy and write into
- `$offset` — 0-based byte offset
- `$data` — bytes to overlay
## Examples
def buf [bin/set-bytes [bin/bytes "AB..CD"] 2 "XY"] [bytes/len $buf] # → 6 [str $buf] # → "ABXYCD"
## Returns
New byte string. A negative offset or an overlay that runs past the end
returns `%Err{:message}`.
## See Also
`bin/set-u8`, `bin/bytes-at`, `bin/bytes`