るりまサーチ

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

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. dsa p
  5. rsa p

クラス

モジュール

オブジェクト

キーワード

検索結果

<< 1 2 3 ... > >>

KeyError#key -> object (21127.0)

KeyError の原因となったメソッド呼び出しのキーを返します。

...
Key
Error の原因となったメソッド呼び出しのキーを返します。

@raise ArgumentError キーが設定されていない時に発生します。

例:

h = Hash.new
begin
h.fetch('gumby'*20)
rescue KeyError => e
p
e.message # => "key not found: \"gumbygumby...
...gumbygumbygumbygumbygumbygumbygumbygumbygumbygumbyg..."
p
'gumby'*20 == e.key # => true
end...

Hash#key(val) -> object (18139.0)

値 val に対応するキーを返します。対応する要素が存在しない時には nil を返します。

...obsolete です。
使用すると警告メッセージが表示されます。

@param val 探索に用いる値を指定します。

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

p
h.key("some") #=> :ab
p
h.key("all") #=> :cd
p
h.key("at") #=> nil
//}

@see Hash#invert...
...キーが複数存在する場合、どのキーを返すかは不定です。


@param val 探索に用いる値を指定します。

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

p
h.key("some") #=> :ab
p
h.key("all") #=> :cd
p
h.key("at") #=> nil
//}

@see Hash#invert...

Errno::EKEYEXPIRED (12002.0)

システムコールのエラーコードを表す例外クラスです。詳細は Errno::EXXX を参照してください。

システムコールのエラーコードを表す例外クラスです。詳細は Errno::EXXX を参照してください。

Proc#ruby2_keywords -> proc (9202.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.

...e 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 sp...
...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.

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

This method will probably be removed at some point, as it exists only
for 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...

Hash#default_proc=(pr) (6280.0)

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

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

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

引数には to_proc で Proc オブジェクトに変換できる
オブジェクト...
...の Hash#default_proc をクリアします。

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

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

end
end
p
h[1] # => 1
p
h[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 になったの...

絞り込み条件を変える

ENV.each_key {|key| ... } -> self (6263.0)

key を引数としてブロックを評価します。

...key を引数としてブロックを評価します。

//emlist[][ruby]{
ENV['FOO'] = 'bar'
ENV.each_key do |key|
p
"key #{key} detected" if key == 'FOO'
end
# "key FOO detected"
//}...

Hash#has_key?(key) -> bool (6254.0)

ハッシュが key をキーとして持つ時真を返します。

...ハッシュが key をキーとして持つ時真を返します。

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

//emlist[][ruby]{
p
({1 => "one"}.key?(1)) # => true
p
({1 => "one"}.key?(2)) # => false
//}

@see Hash#value?...

Hash#key?(key) -> bool (6254.0)

ハッシュが key をキーとして持つ時真を返します。

...ハッシュが key をキーとして持つ時真を返します。

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

//emlist[][ruby]{
p
({1 => "one"}.key?(1)) # => true
p
({1 => "one"}.key?(2)) # => false
//}

@see Hash#value?...

Hash#default_proc -> Proc | nil (6244.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 #=> #<Pro...
...c: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#each_key {|key| ... } -> self (6235.0)

ハッシュのキーを引数としてブロックを評価します。

...れた順です。
ブロック付きの場合selfを、
無しで呼ばれた場合Enumeratorを返します。

//emlist[例][ruby]{
{:a=>1, :b=>2}.each_key {|k| p k}
#=> :a
# :b

p
({:a=>1, :b=>2}.each_key) # => #<Enumerator: {:a=>1, :b=>2}:each_key>
//}

@see Hash#each_pair,Hash#each_value...

絞り込み条件を変える

<< 1 2 3 ... > >>