Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
#!/usr/bin/env ruby
class FooBar
include Enumerable
def initialize( array1 , array2 )
@array_out = Array.new
if array1 != [] and array2 != []
for i in array1
for j in array2
k = [i,j].join("|")
@array_out.push( k )
end
end
end
end
def each
current_index = 0
while current_index < @array_out.size
yield @array_out[current_index]
current_index += 1
end
end
end
class Array
def reverse_iterate
current_index = self.size-1
while current_index >= 0
yield self[current_index]
current_index -= 1
end
end
end
#[2,4,5,6,9].reverse_iterate { |i| puts i.inspect }
x = FooBar.new( (1..3) , [4,6] )
x.each{ |i| puts i.inspect }
y = FooBar.new( [ 'A' , 'B' , 'a' , 'b' ] , [4,6] )
y.each{ |i| puts i.inspect }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.