struct

Slice(T)

Inherits Comparable < Indexable::Mutable < Indexable < Enumerable < Iterable < Struct < Value < Object

A Slice is a Pointer with an associated size.

While a pointer is unsafe because no bound checks are performed when reading from and writing to it, reading from and writing to a slice involve bound checks. In this way, a slice is a safe alternative to Pointer.

A Slice can be created as read-only: trying to write to it will raise. For example the slice of bytes returned by String#to_slice is read-only.

Constants

BYTE_TO_HEX_MAP = (0..255).each.with_index.map do |v, i| (i.to_s(16)).rjust(2, '0') end.to_a

Instance methods

to_hex

assumes Slice(UInt8)

Source