has been released recently.
method was introduced with the release.
This is equivalent to
The feature returns random bytes
the length argument passed to it.
We need Ruby 2.6.0 version to try out this feature.
Install Ruby 2.6.0
As we have previw versions released,
we can install
as given below.
Random.bytes(length) - where
length is an integer argument.
Returns random binary string for the length / size argument passed to it.
Prior to Ruby 2.6
When we want to get random binary string,
we had to call
bytes method on an object
After Ruby 2.6
adds an ability to call
bytes method on Random class directly.
As we can observe, it returns random binary string
similar to method
If we call
it always returns an empty string