Remove nil item
@array.compact #=> [ 1, 3, 5 ]
Count total of nil item
@array.length #=> 5
@array.nitems #=> 3
total_nil = @array.length - @array.nitems
Check the present of nil item
@array.include?nil #=> true
Location of the nil item
@array.index(nil) #=> 1
Refer site: http://ruby-doc.org/core/classes/Array.html
If you find this useful, would you like to buy me a drink? No matter more or less, it will be an encouragement for me to go further. Thanks in advance!! =)
Thanks a lot! Very helpful.
ReplyDeletewelcome =)
ReplyDeletethanks in advance, you saved my life
ReplyDelete