Add sub array includes in ruby

This commit is contained in:
Wilfried OLLIVIER 2020-04-17 14:37:11 +02:00
parent 3ec1848c3e
commit be6d34ff20
1 changed files with 9 additions and 1 deletions

View File

@ -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
```