るりまサーチ

最速Rubyリファレンスマニュアル検索!
144件ヒット [101-144件を表示] (0.071秒)

別のキーワード

  1. uri default_port
  2. _builtin default
  3. socket ai_default
  4. generic default_port
  5. socket ip_default_multicast_ttl

ライブラリ

キーワード

検索結果

<< < 1 2 >>

Hash#[](key) -> object | nil (26.0)

key に関連づけられた値を返します。

... Hash#fetch または Hash#key? を使ってください。

@param key 探索するキーを指定します。

//emlist[例][ruby]{
h = {:ab => "some" , :cd => "all"}
p h[:ab] #=> "some"
p h[:ef] #=> nil

h1 = Hash.new("default value")
p h1[:non] #=> "default va...
...lue"

h2 = Hash.new {|*arg| arg}
p h2[:non] #=> [{}, :non]
//}

@see Hash.new, Hash#fetch,Hash#values_at,Hash#key?, Hash#default, Hash#default_proc...

Hash#shift -> [object, object] | nil (26.0)

ハッシュからキーが追加された順で先頭の要素をひとつ取り除き、 [key, value]という配列として返します。

...り除かれた残りのハッシュに変更されます。

Ruby 3.2以前は、ハッシュが空の場合、デフォルト値(Hash#defaultまたはHash#default_procのブロックの値か、どちらもnilならばnil)
を返します(このとき、[key,value] という形式の値を返...
...#=> [:cd, "all"]
p h #=> {}
p h.shift #=> nil

h1 = Hash.new("default value")
p h1 #=> {}
p h1.shift #=> "default value"

h2 = Hash.new {|*arg| arg}
p h2 #=> {}
p h2.shift #=> [{}, nil]
//}


@...

Hash#clear -> self (20.0)

ハッシュの中身を空にします。

...ハッシュの中身を空にします。

空にした後のselfを返します。
デフォルト値の設定はクリアされません。

//emlist[例][ruby]{
h = Hash.new("default value")
h[:some] = "some"
p h #=> {:some=>"some"}

h.clear

p h #=> {}
p h.default #=> "default value"
//}...

Hash#values_at(*keys) -> [object] (14.0)

引数で指定されたキーに対応する値の配列を返します。

...引数が指定されなかった場合は、空の配列を返します。

//emlist[例][ruby]{
h = {1=>"a", 2=>"b", 3=>"c"}

p h.values_at(1,3,4) #=> ["a", "c", nil]
# [h[1], h[3] ,h[4]] と同じ
//}

@see Hash#[] , Hash.new, Hash#default, Hash#default_proc, Array#values_at...

Hash#shift -> [object, object] | nil (8.0)

ハッシュからキーが追加された順で先頭の要素をひとつ取り除き、 [key, value]という配列として返します。

...#=> [:cd, "all"]
p h #=> {}
p h.shift #=> nil

h1 = Hash.new("default value")
p h1 #=> {}
p h1.shift #=> nil

h2 = Hash.new {|*arg| arg}
p h2 #=> {}
p h2.shift #=> nil
//}


@see Array#sh...

絞り込み条件を変える

<< < 1 2 >>