Class: Subarray

Inherits:
Object
  • Object
show all
Defined in:
lib/subarray.rb

Class Method Summary collapse

Class Method Details

.get_tuple_of_size(array, size) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/subarray.rb', line 2

def self.get_tuple_of_size(array,size)
 sub_array = []
 tuple =[]
 array.each_with_index do |element,index|
    inner_index = index
  size.to_i.times do 
     tuple << array[inner_index] 
     inner_index +=1
  end
  sub_array << tuple if !tuple.include?(nil)
tuple = []
end
return sub_array
end