Reputation: 31
I'm having trouble checking if a nested array contains a single array. For example:
a = [[1,2], [3,4]]
a.each do |i|
b= i.inspect
puts a.include?(b)
end
The output it false and false. If anyone could help out that would be great.
Upvotes: 1
Views: 2168
Reputation: 1072
a = [[1,2], [3,4]]
a.each do |i|
# puts i.to_s
puts a.include?(i)
end
This should do it. inspect
is not necessary. This outputs true and true. Uncomment the comment in the code to see the output.
Upvotes: 1