るりまサーチ

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

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

モジュール

検索結果

<< 1 2 3 ... > >>

Hash#key(val) -> object (18126.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...

Module#ruby2_keywords(method_name, ...) -> nil (12232.0)

For the given method names, marks the method as passing keywords through a normal argument splat. This should only be called on methods that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the method such that if the method 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 method to other methods.

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

This should only be used for methods that delegate keywords to another
method, and only for backwards compatibility with Ruby versions...
...ility. As it does not exist in Ruby versions
before 2.7, check that the module responds to this method before calling
it. Also, be aware that if this method is removed, the behavior of the
method will change so that it does not pass through keywords.

//emlist[例][ruby]{
module Mod
def foo(meth,...

Proc#ruby2_keywords -> proc (12232.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...
...ude 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 another
method, and only for backwards compatibility with Ruby versions be...
...atibility. 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
foo = ->(meth, *a...

Net::HTTPHeader#key?(key) -> bool (6259.0)

key というヘッダフィールドがあれば真を返します。 key は大文字小文字を区別しません。

...key というヘッダフィールドがあれば真を返します。
key
は大文字小文字を区別しません。

@param key 探すヘッダフィールド名を文字列で与えます。

//emlist[例][ruby]{
require 'net/http'

uri = URI.parse('http://www.example.com/index.html')
res = Ne...
...t::HTTP.get_response(uri)
res.key?('content-type') # => true
res.key?('nonexist-header') # => false
//}...

Hash#has_key?(key) -> bool (6247.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 (6247.0)

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

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

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

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

@see Hash#value?...

Hash#each_key {|key| ... } -> self (6228.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...

Hash#transform_keys {|key| ... } -> Hash (6208.0)

すべてのキーに対してブロックを呼び出した結果で置き換えたハッシュを返します。 値は変化しません。

...を返します。
値は変化しません。


//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h.transform_keys {|k| k.to_s } # => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys(&:to_s) # => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys.with_index {|k, i| "#{k}.#{i}" }...
...# => {"a.0"=>1, "b.1"=>2, "c.2"=>3}
//}

@see Hash#transform_keys!
@see Hash#transform_values
@see Hash#transform_values!...
...定します。

//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h.transform_keys {|k| k.to_s } # => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys(a: "a", d: "d") # => {"a"=>1, :b=>2, :c=>3}
h.transform_keys(&:to_s) # => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys.with_index {|k, i| "#{k}.#{i}" }...

Hash#transform_keys! {|key| ... } -> self (6208.0)

すべてのキーに対してブロックを呼び出した結果でハッシュのキーを変更します。 値は変化しません。

...ransform_keys! は常に self を返します。
ブロックが与えられなかった場合は、Enumerator オブジェクトを
返します。


//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h.transform_keys! {|k| k.to_s } # => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys!(&:to_...
...sym) # => {:a=>1, :b=>2, :c=>3}
h.transform_keys!.with_index {|k, i| "#{k}.#{i}" }
# => {"a.0"=>1, "b.1"=>2, "c.2"=>3}
//}

@see Hash#transform_keys
@see Hash#transform_values
@see Hash#transform_values!...
...sym) # => {:a=>1, :b=>2, :c=>3}
h.transform_keys!(a: "a", d: "d") # => {"a"=>1, :b=>2, :c=>3}
h.transform_keys!.with_index {|k, i| "#{k}.#{i}" }
# => {"a.0"=>1, "b.1"=>2, "c.2"=>3}
//}

@see Hash#transform_keys
@see Hash#transform_values
@see Hash#transform_va...

CSV::Row#deconstruct_keys(keys) -> Hash (6207.0)

パターンマッチに使用するヘッダの名前と値の Hash を返します。

...をシンボルに変換する必要があります。

@param keys パターンマッチに使用するヘッダの名前の配列を指定します。nil の場合は全てをパターンマッチに使用します。

//emlist[例][ruby]{
require "csv"

row = CSV::Row.new([:header1, :header2, :he...

絞り込み条件を変える

Hash#each_key -> Enumerator (6128.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 ... > >>