Project

General

Profile

Feature #17833

Updated by dsisnero (Dominic Sisneros) about 1 year ago

``` ruby 
 assuming you have a ByteArray class that we can get a memoryview from 

 ba = ByteArray.new(8) # #17834  

 

 mv_at_4 = Fiddle::MemoryView.new(ba)[4..-1] 

 f = File.open('/dev/urandom', 'rb'){|s| s.readinto(mv_at_4) # write the content of /dev/urandom from offset 4 to the end of the bytearray, effectively reading only 4 bytes 
 ``` 

Back