Ruby - include? returning false when object is indeed in array -


my_hash = hash.new{|h,k| h[k] = []} name = 'john' my_hash[name] << '7' my_hash[name] << '9' name = 'jane' my_hash[name] << '7' my_hash[name] << 'j'  array_info = my_hash.values_at('john') puts array_info.class                   => array  array_info.each |ele|    puts ele                             => 7, 9 end removed = array_info.include?('7') puts removed                           => false ??!?!????? 

array_info printed 7 element in array, know exists. why array_info.include?('7') not return true??

take @ array_info. puts-ing shows ele values indeed in array, array nested inside array.

removed = array_info.first.include?('7') 

will return true.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -