データの有無を調査
Top > Ruby [2.2.2] > include / member
p [1,2,3,4,5].include?(3) # true p ["1","2","3","4","5"].include?("3") # true p [1,2,3,4,5].include?(0) # false p ["1","2","3","4","5"].include?(3) # false p [1,2,3,4,5].member?(3) # true p ["1","2","3","4","5"].member?("3") # true p [1,2,3,4,5].member?(0) # false p ["1","2","3","4","5"].member?(3) # false test_hash = {"acha"=>100, "porute"=>200, "piipo"=>300} p test_hash.include?('piipo') #=> true p test_hash.member?('orz') #=> false p test_hash.key?('acha') #=> true p test_hash.has_key?('porute') #=> true