るりまサーチ

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

別のキーワード

  1. _builtin to_proc
  2. _builtin proc
  3. proc curry
  4. httpserver mount_proc
  5. readline completion_proc

ライブラリ

クラス

キーワード

検索結果

<< 1 2 > >>

Proc#hash -> Integer (39126.0)

self のハッシュ値を返します。

...self のハッシュ値を返します。



Proc
オブジェクトの引数の情報を返します。

Proc
オブジェクトが引数を取らなければ空の配列を返します。引数を取る場合は、配列の配列を返し、
各配列の要素は引数の種類に対応した以...
...を表す Symbol の 2 要素です。

//emlist[][ruby]{
prc = proc{|x, y=42, *other|}
p prc.parameters # => x], [:opt, :y], [:rest, :other
prc = lambda{|x, y=42, *other|}
p prc.parameters # => x], [:opt, :y], [:rest, :other
prc = proc{|x, y=42, *other|}
p prc.parameters(lambda: true) # => x], [...

Proc#ruby2_keywords -> proc (21194.0)

Marks the proc as passing keywords through a normal argument splat. This should only be called on procs that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the proc such that if the proc is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the proc to other methods.

...Marks the proc as passing keywords through a normal argument splat. This
should only be called on procs that accept an argument splat (`*args`)
but not explicit keywords or a keyword splat. It marks the proc such
that if the proc is called with keyword arguments, the final hash
argument is marked...
...ds or a keyword splat, the
final element is interpreted as keywords. In other words, keywords will
be passed through the proc to other methods.

This should only be used for procs that delegate keywords to another
method, and only for backwards compatibility with Ruby versions before
2.7.

This met...
...backwards compatibility. As it does not exist in Ruby versions
before 2.7, check that the proc responds to this method before calling
it. Also, be aware that if this method is removed, the behavior of the
proc
will change so that it does not pass through keywords.

//emlist[][ruby]{
module Mod
fo...

Hash#default_proc -> Proc | nil (15267.0)

ハッシュのデフォルト値を返す Proc オブジェクトを返します。 ハッシュがブロック形式のデフォルト値を持たない場合 nil を返します。

... Proc オブジェクトを返します。
ハッシュがブロック形式のデフォルト値を持たない場合 nil を返します。

//emlist[例][ruby]{
h = Hash.new {|hash, key| "The #{key} not exist in #{hash.inspect}"}
p h.default #=> nil
p block = h.default_proc #=> #<...
...Proc:0x0x401a9ff4>
p block.call({},:foo) #=> "The foo not exist in {}"

h = Hash.new("default")
p h.default #=> "default"
p h.default_proc #=> nil
//}

@see Hash#default...

Hash#default_proc=(pr) (15220.0)

ハッシュのデフォルト値を返す Proc オブジェクトを 変更します。

...ハッシュのデフォルト値を返す Proc オブジェクトを
変更します。

以前のデフォルトは値(Hash#default)の場合も
Proc
の場合(Hash#default_proc)でも上書きされます。

引数には to_proc Proc オブジェクトに変換できる
オブジェクト...
...け付けます。

nil を指定した場合は現在の Hash#default_proc をクリアします。

@param pr デフォルト値を返す手続きオブジェクト

//emlist[例][ruby]{
h = {}
h.default_proc = proc do |hash, key|
hash
[key] = case
when (key % 15).zero?...
...2] # => 2
p h[3] # => "Fizz"
p h[5] # => "Buzz"
p h[15] # => "FizzBuzz"

h.default_proc = nil
p h[16] # => nil
# default_proc が nil になったので `16=>16 が追加されていない`
p h # => {1=>1, 2=>2, 3=>"Fizz", 5=>"Buzz", 15=>"FizzBuzz"}
//}

@see Hash#default_proc, Hash#default...

Hash#to_proc -> Proc (15219.0)

self のキーに対応する値を返す Proc オブジェクトを返します。

...self のキーに対応する値を返す Proc オブジェクトを返します。

//emlist[][ruby]{
h = {1 => 10, 2 => 20, 3 => 30}
[1, 2, 3].map(&h) # => [10, 20, 30]
//}...

絞り込み条件を変える

Shell::CommandProcessor#rehash -> {} (9101.0)

登録されているシステムコマンドの情報をクリアします。 通常、使うことはありません。

登録されているシステムコマンドの情報をクリアします。
通常、使うことはありません。

Hash#[](key) -> object | nil (9067.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 value"

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#default -> object | nil (9061.0)

ハッシュのデフォルト値を返します。

...なることに注意してください。この場合、ハッシュのデフォルト値に
ついて調べるには 2 番目の形式か Hash#default_proc を使ってください。

2 番目の形式はハッシュがデフォルト値としてブロックを持つ場合に、
self と引数 ke...
...emlist[例][ruby]{
h = Hash.new("default")
p h.default #=> "default"
p h.default(:some) #=> "default"
p h #=>{}

h = Hash.new{|hash, key| hash[key] ="default" }
p h.default #=> nil
p h.default(:some) #=> "default"
p h #=> {:some=>"default"}

h = Hash.new
p h.default...
...#=> nil
p h.default(:some) #=> nil
p h #=> {}
//}

@see Hash#default=, Hash#default_proc...

Hash#default(key) -> object | nil (9061.0)

ハッシュのデフォルト値を返します。

...なることに注意してください。この場合、ハッシュのデフォルト値に
ついて調べるには 2 番目の形式か Hash#default_proc を使ってください。

2 番目の形式はハッシュがデフォルト値としてブロックを持つ場合に、
self と引数 ke...
...emlist[例][ruby]{
h = Hash.new("default")
p h.default #=> "default"
p h.default(:some) #=> "default"
p h #=>{}

h = Hash.new{|hash, key| hash[key] ="default" }
p h.default #=> nil
p h.default(:some) #=> "default"
p h #=> {:some=>"default"}

h = Hash.new
p h.default...
...#=> nil
p h.default(:some) #=> nil
p h #=> {}
//}

@see Hash#default=, Hash#default_proc...

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

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

...elfは要素を取り除かれた残りのハッシュに変更されます。

ハッシュが空の場合、デフォルト値(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]
//}

@s...

絞り込み条件を変える

Hash#values_at(*keys) -> [object] (9031.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...
<< 1 2 > >>