skip to main
|
skip to sidebar
Technology blog - Sabu Thaliyath
Friday, May 6, 2011
Compare two arrays in Ruby
Today I had a need to compare 2 arrays in Ruby and if they are the same, then do something else something. I googled and found this solution
Let us say a1 and a2 are the arrays then
diff=a1-a2
if diff.empty ? then
puts "arrays are the same"
else
puts "arrays are different"
end
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
SiteMeter
Blog Archive
▼
2011
(3)
►
October
(1)
▼
May
(1)
Compare two arrays in Ruby
►
April
(1)
►
2010
(5)
►
November
(1)
►
September
(2)
►
August
(1)
►
April
(1)
►
2009
(8)
►
September
(3)
►
August
(1)
►
May
(3)
►
April
(1)
►
2008
(5)
►
October
(1)
►
September
(4)
No comments:
Post a Comment