From: Soul Surf Date: 2012-04-13T16:44:45+09:00 Subject: Re: How to test if array element exists? thanks. let me change the array to make it more clear what i'm trying to test .. M='M' array = [M,M,M,M] if [array[4]].empty? puts 'empty' end if [array[4]].nil? puts 'nil' end my array has 4 elements, all of them are 'M'. array[0] is M ... to array[3] is M ... but array[4] doesn't exist. what if statement can I write that will tell me that array[4] doesn't exist? the two if statements above return false. -- Posted via http://www.ruby-forum.com/.