From: Soul Surf Date: 2012-04-13T16:31:16+09:00 Subject: How to test if array element exists? I'm new to Ruby and just want to test if an array element exists. Here's a basic code snippet: array = [0,1,2,3] if [array[4]].empty? puts 'empty' end if [array[4]].nil? puts 'nil' end element 4 does not exist in the array, but neither of the if statements result in true? what would be an if statement to check that array[4] does not exist? Thanks -- Posted via http://www.ruby-forum.com/.