Add sub array includes in ruby
This commit is contained in:
parent
3ec1848c3e
commit
be6d34ff20
1 changed files with 9 additions and 1 deletions
|
@ -1,6 +1,14 @@
|
||||||
# Check if all array elements are equals
|
# Playing with arrays
|
||||||
|
|
||||||
|
## Check if all array elements are equals
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
arr = [0, 0, 0, 0, 0, 0, 0]
|
arr = [0, 0, 0, 0, 0, 0, 0]
|
||||||
puts true if arr.uniq.length == 1
|
puts true if arr.uniq.length == 1
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Array includes a sub array
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
(subarray & array) == array
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in a new issue