From: Adgar Marks Date: 2008-08-20T01:13:28+09:00 Subject: Find element in array of hashes Dear all, i am trying to find my way in Ruby, but i am just a bignner. Here is my problem: I have two array of hashes: _DownloadData << { :FileName => splitLine[0] , :Size => splitLine[4].to_i } _FilesData << { :FileName => splitLine[8] , :Year => year , :Month => month , :Day => day , :Suffix => suffix , :JDay => jday , :Size => splitLine[4].to_i } I would like to know if FileName from _FileesData is in _DownloadData and later or if the two files have the same size. I tried to write it like this: if _DownloadData[:FileName].include?( _FilesData[:FileName] ) and i already got an error. what i would like to write is something like this: _FilesData.sort_by {|hash| hash.values_at(:Year, :Month, :Day, :Suffix ) }.each do |hash| if _DownloadData[:FileName].include?( hash[:FileName] ) index = _DownloadData[:FileName].index?( _FilesData[:FileName] ) if _DownloadData[:FileName](index) == _FilesData[:FileName] # do something else # do something else end end end My questions are: how do i fine an element of array of hashes in another array of hashes? How do i get accuess an array of hashes at a certen index. Thanks -- Posted via http://www.ruby-forum.com/.