Ruby 1.9.3 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > Hashクラス > length

instance method Hash#length

length -> Integer
size -> Integer

ハッシュの要素の数を返します。

puts({ant: 9 ,dog: 101 ,cat: 3}.length) #=> 3
class Hash