312件ヒット
[1-100件を表示]
(0.050秒)
別のキーワード
種類
- インスタンスメソッド (204)
- モジュール関数 (55)
- 特異メソッド (44)
- クラス (9)
クラス
- Array (33)
- BasicObject (22)
- Method (11)
- Proc (6)
- String (11)
- Thread (22)
- UnboundMethod (33)
モジュール
- Enumerable (55)
- GC (55)
- ObjectSpace (55)
キーワード
- ! (11)
- != (11)
- << (6)
- ConditionVariable (9)
- arity (22)
-
count
_ objects (11) -
each
_ object (44) -
garbage
_ collect (11) - inspect (11)
- priority (11)
- priority= (11)
-
sort
_ by (22) - start (11)
- stat (22)
-
to
_ s (11)
検索結果
先頭5件
-
String
# count(*chars) -> Integer (18133.0) -
chars で指定された文字が文字列 self にいくつあるか数えます。
...文字のパターン
//emlist[例][ruby]{
p 'abcdefg'.count('c') # => 1
p '123456789'.count('2378') # => 4
p '123456789'.count('2-8', '^4-6') # => 4
# ファイルの行数を数える
n_lines = File.read("foo").count("\n")
# ファイルの末尾に改行コードがな......い場合にも対処する
buf = File.read("foo")
n_lines = buf.count("\n")
n_lines += 1 if /[^\n]\z/ =~ buf
# if /\n\z/ !~ buf だと空ファイルを 1 行として数えてしまうのでダメ
//}... -
Array
# count -> Integer (18129.0) -
レシーバの要素数を返します。
...ブロックを評価して真になった要素の個数を
カウントして返します。
@param item カウント対象となる値。
//emlist[例][ruby]{
ary = [1, 2, 4, 2.0]
ary.count # => 4
ary.count(2) # => 2
ary.count{|x|x%2==0} # => 3
//}
@see Enumerable#count... -
Array
# count {|obj| . . . } -> Integer (18129.0) -
レシーバの要素数を返します。
...ブロックを評価して真になった要素の個数を
カウントして返します。
@param item カウント対象となる値。
//emlist[例][ruby]{
ary = [1, 2, 4, 2.0]
ary.count # => 4
ary.count(2) # => 2
ary.count{|x|x%2==0} # => 3
//}
@see Enumerable#count... -
Array
# count(item) -> Integer (18129.0) -
レシーバの要素数を返します。
...ブロックを評価して真になった要素の個数を
カウントして返します。
@param item カウント対象となる値。
//emlist[例][ruby]{
ary = [1, 2, 4, 2.0]
ary.count # => 4
ary.count(2) # => 2
ary.count{|x|x%2==0} # => 3
//}
@see Enumerable#count... -
Enumerable
# count -> Integer (18129.0) -
レシーバの要素数を返します。
...価して真になった要素の個数を
カウントして返します。
@param item カウント対象となる値。
//emlist[例][ruby]{
enum = [1, 2, 4, 2].each
enum.count # => 4
enum.count(2) # => 2
enum.count{|x|x%2==0} # => 3
//}
@see Array#count... -
Enumerable
# count {|obj| . . . } -> Integer (18129.0) -
レシーバの要素数を返します。
...価して真になった要素の個数を
カウントして返します。
@param item カウント対象となる値。
//emlist[例][ruby]{
enum = [1, 2, 4, 2].each
enum.count # => 4
enum.count(2) # => 2
enum.count{|x|x%2==0} # => 3
//}
@see Array#count... -
Enumerable
# count(item) -> Integer (18129.0) -
レシーバの要素数を返します。
...価して真になった要素の個数を
カウントして返します。
@param item カウント対象となる値。
//emlist[例][ruby]{
enum = [1, 2, 4, 2].each
enum.count # => 4
enum.count(2) # => 2
enum.count{|x|x%2==0} # => 3
//}
@see Array#count... -
GC
. count -> Integer (18109.0) -
プロセス開始からガーベージコレクトを実行した回数を Integer で返し ます。
...プロセス開始からガーベージコレクトを実行した回数を Integer で返し
ます。
//emlist[例][ruby]{
GC.count # => 3
//}... -
ObjectSpace
. # count _ objects(result _ hash = {}) -> Hash (6109.0) -
オブジェクトを種類ごとにカウントした結果を Hash として返します。
...これを利用すると測定による影響を避けることができます。
@raise TypeError 引数に Hash 以外を与えた場合、発生します。
//emlist[例][ruby]{
ObjectSpace.count_objects # => {:TOTAL=>10000, :FREE=>3011, :T_OBJECT=>6, :T_CLASS=>404, ...}
//}... -
ObjectSpace
. # each _ object -> Enumerator (50.0) -
指定された klass と Object#kind_of? の関係にある全ての オブジェクトに対して繰り返します。引数が省略された時には全てのオブ ジェクトに対して繰り返します。 繰り返した数を返します。
...を扱う][ruby]{
ObjectSpace.each_object.take(5).each { |x| p x }
count = ObjectSpace.each_object { |x| x }
puts "Total count: #{count}"
# => "scope"
# => "scopes"
# => "sym"
# => "class_names"
# => "@corrections"
# => Total count: 9938
//}
//emlist[例: 任意のクラスを扱う][ruby]{
Person......= Struct.new(:name)
s1 = Person.new("tanaka")
s2 = Person.new("sato")
count = ObjectSpace.each_object(Person) { |x| p x }
puts "Total count: #{count}"
# => #<struct Person name="sato">
# => #<struct Person name="tanaka">
# => Total count: 2
//}...