bytes.slice
bytes.slice
Function
Intercept the byte range of Bytes and return new Bytes.
Syntax
bytes(value).slice(start, end)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| start | Int | No | 0 | Starting index, including this position. Supports counting negative numbers from the tail. |
| end | Int | No | Length in bytes | End index, excluding this position. Supports counting negative numbers from the tail. |
Return value
| Type | Description |
|---|---|
| Bytes | New Bytes after interception. |
Code Example
data = bytes('425400', 'hex') part = data.slice(0, 2) // Output: 4254 print part.to_hex()
Notes
- Returns empty Bytes when
start >= end.