Skip to main content
Say What???
Ain't got a slogan...

Main menu

  • Home
  • Archived Articles

You are here

Home » Ruby 1.8 Method of the Day Archive

Array.nitems

Kelly McCauley's picture
published by Kelly McCauley on Wed, 10/27/2010 - 20:39

Signature

array.nitems    #=> integer

array.nitems returns the number of non-nil elements contained
in array.

Examples

a = [1, 2, 3, 4, 5]
a.nitems                    #=> 5
a = [1, nil, nil, 4, nil]
a.nitems                    #=> 2
a = [nil, nil, nil, nil]
a.nitems                    #=> 0

Documentation Reference

Ruby version 1.8.6

www.ruby-doc.org : Array.nitems

‹ Array.map! and Array.collect! up Array.pop ›
  • Log in to post comments

Ruby 1.8 Method of the Day Archive

  • Array.&
  • Array.+
  • Array.-
  • Array.<< and Array.push
  • Array.[] and Array.slice
  • Array.[]=
  • Array.abbrev
  • Array.assoc
  • Array.compact and Array.compact!
  • Array.delete
  • Array.delete_if
  • Array.fetch
  • Array.first
  • Array.last
  • Array.map and Array.collect
  • Array.map! and Array.collect!
  • Array.nitems
  • Array.pop
  • Array.rassoc
  • Array.reject
  • Array.reject!
  • Array.slice!
  • Float.ceil
  • Float.floor
  • Float.truncate
  • Integer.downto
  • Integer.times
  • Integer.upto
  • String.%
  • String.*
  • String.+
  • String.<=>
  • String.==
  • String.=~
  • String.[]
  • String.[]=
  • String.casecmp
  • String.center
  • String.count
  • String.delete
  • String.delete!
  • String.gsub
  • String.gsub!
  • String.hex
  • String.index
  • String.insert
  • String.inspect
  • String.length
  • String.ljust
  • String.lstrip
  • String.lstrip!
  • String.next
  • String.reverse
  • String.rindex
  • String.rjust
  • String.rstrip
  • String.rstrip!
  • String.scan
  • String.strip
  • String.strip!
  • String.sub
  • String.to_sym

User login

  • Request new password

Syndicate

Subscribe to Syndicate

Content Copyright © Kelly McCauley, All Rights Reserved. Trademarks and copyrights are owned by their respective owners. Comments are owned by the commenter.