You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,23 @@ ba.total_set
47
47
#=> 7
48
48
```
49
49
50
+
Initializing `BitArray` with a custom field value:
51
+
52
+
```ruby
53
+
ba =BitArray.new(16, ["0000111111110000"].pack('B*'))
54
+
ba.to_s # "1111000000001111"
55
+
```
56
+
57
+
`BitArray` by default stores the bits in reverse order for each byte. If for example, you are initializing `BitArray` with Redis raw value manipulated with `setbit` / `getbit` operations, you will need to tell `BitArray` to not reverse the bits in each byte using the `reverse_byte: false` option:
58
+
59
+
```ruby
60
+
ba =BitArray.new(16, ["0000111111110000"].pack('B*'), reverse_byte:false)
61
+
ba.to_s # "0000111111110000"
62
+
```
63
+
64
+
50
65
## History
66
+
- 1.2 in 2018 (Added option to skip reverse the bits for each byte)
51
67
- 1.1 in 2018 (fixed a significant bug)
52
68
- 1.0 in 2017 (updated for modern Ruby, more efficient storage, and 10th birthday)
0 commit comments