るりまサーチ

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

別のキーワード

  1. _builtin upcase
  2. symbol upcase
  3. string upcase
  4. string upcase!
  5. _builtin upcase!

ライブラリ

クラス

モジュール

キーワード

検索結果

<< < 1 2 3 4 > >>

String#gsub(pattern) {|matched| .... } -> String (13.0)

文字列中で pattern にマッチした部分を順番にブロックに渡し、 その実行結果で置き換えた文字列を生成して返します。 ブロックなしの場合と違い、ブロックの中からは 組み込み変数 $1, $2, $3, ... を問題なく参照できます。

...表現。
文字列を指定した場合は全く同じ文字列にだけマッチする
@return 新しい文字列

//emlist[例][ruby]{
p 'abcabc'.gsub(/[bc]/) {|s| s.upcase } #=> "aBCaBC"
p 'abcabc'.gsub(/[bc]/) { $&.upcase } #=> "aBCaBC"
//}

@see String#sub, String#scan...

String#sub!(pattern) {|matched| .... } -> self | nil (13.0)

文字列中で pattern にマッチした最初の部分をブロックに渡し、 その評価結果へ破壊的に置き換えます。

...は全く同じ文字列にだけマッチする
@return 置換した場合は self、置換しなかった場合は nil

//emlist[例][ruby]{
str = 'abcabc'
str.sub!(/b/) {|s| s.upcase }
p str #=> "aBcabc"

str = 'abcabc'
str.sub!(/b/) { $&.upcase }
p str #=> "aBcabc"
//}

@see String#gsub...

String#sub(pattern) {|matched| .... } -> String (13.0)

文字列中で pattern にマッチした最初の部分をブロックに渡し、 その評価結果で置き換えた新しい文字列を返します。 ブロックなしの sub と違い、ブロックの中からは 組み込み変数 $1, $2, $3, ... を問題なく参照できます。

...字列のパターンを表す文字列か正規表現。
文字列を指定した場合は全く同じ文字列にだけマッチする

//emlist[例][ruby]{
p 'abcabc'.sub(/b/) {|s| s.upcase } #=> "aBcabc"
p 'abcabc'.sub(/b/) { $&.upcase } #=> "aBcabc"
//}

@see String#gsub...

Data#with(**kwargs) -> Data (7.0)

self をコピーしたオブジェクトを返します。

...gumentError (unknown keyword: :type)

# メンバのオブジェクトはコピーされず、同じオブジェクトを参照する。
dog1.name.upcase!
p dog1 # => #<data Dog name="FRED", age=5>
p dog2 # => #<data Dog name="FRED", age=6>
//}

[注意] 本メソッドの記述は Data のサブク...

FileUtils#ruby(*args) {|result, status| ... } (7.0)

与えられた引数で Ruby インタプリタを実行します。

...与えられた引数で Ruby インタプリタを実行します。

@param args Ruby インタプリタに与える引数を指定します。

例:
ruby %{-pe '$_.upcase!' <README}

@see Kernel.#sh...

絞り込み条件を変える

Hash#clone -> Hash (7.0)

selfと同じ内容を持つ新しいハッシュを返します。

...//emlist[例][ruby]{
h1 = {"have" => "have a","as" => "as a" }
h2 = h1.dup

h2["have"] = "has"
p h2 #=> {"have"=>"has", "as"=>"as a"}
p h1 #=> {"have"=>"have a", "as"=>"as a"}

h2["as"].upcase!
p h2 #=> {"have"=>"has", "as"=>"AS A"}
p h1 #=> {"have"=>"have a", "as"=>"AS A"}
//}

@see Object#clone...

Hash#dup -> Hash (7.0)

selfと同じ内容を持つ新しいハッシュを返します。

...//emlist[例][ruby]{
h1 = {"have" => "have a","as" => "as a" }
h2 = h1.dup

h2["have"] = "has"
p h2 #=> {"have"=>"has", "as"=>"as a"}
p h1 #=> {"have"=>"have a", "as"=>"as a"}

h2["as"].upcase!
p h2 #=> {"have"=>"has", "as"=>"AS A"}
p h1 #=> {"have"=>"have a", "as"=>"AS A"}
//}

@see Object#clone...

Hash#fetch_values(key, ...) -> [object] (7.0)

引数で指定されたキーに関連づけられた値の配列を返します。

...=> "feline", "dog" => "canine", "cow" => "bovine" }

h.fetch_values("cow", "cat") # => ["bovine", "feline"]
h.fetch_values("cow", "bird") # raises KeyError
h.fetch_values("cow", "bird") { |k| k.upcase } # => ["bovine", "BIRD"]
//}

@see Hash#values_at, Hash#fetch...

Hash#fetch_values(key, ...) { |key| ... } -> [object] (7.0)

引数で指定されたキーに関連づけられた値の配列を返します。

...=> "feline", "dog" => "canine", "cow" => "bovine" }

h.fetch_values("cow", "cat") # => ["bovine", "feline"]
h.fetch_values("cow", "bird") # raises KeyError
h.fetch_values("cow", "bird") { |k| k.upcase } # => ["bovine", "BIRD"]
//}

@see Hash#values_at, Hash#fetch...

Hash#to_h -> self | Hash (7.0)

self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。

...sh
//}

ブロックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
hash = { "a" => 97, "b" => 98 }
hash.to_h {|key, value| [key.upcase, value-32] } # => {"A"=>65, "B"=>66}
//}

@see Enumerable#map...

絞り込み条件を変える

Hash#to_h {|key, value| block } -> Hash (7.0)

self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。

...sh
//}

ブロックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。
//emlist[ブロック付きの例][ruby]{
hash = { "a" => 97, "b" => 98 }
hash.to_h {|key, value| [key.upcase, value-32] } # => {"A"=>65, "B"=>66}
//}

@see Enumerable#map...

Object#then -> Enumerator (7.0)

self を引数としてブロックを評価し、ブロックの結果を返します。

...、ブロックの結果を返します。

//emlist[例][ruby]{
3.next.then {|x| x**x }.to_s # => "256"
"my string".yield_self {|s| s.upcase } # => "MY STRING"
//}

値をメソッドチェインのパイプラインに次々と渡すのは良い使い方です。

//emlist[メソッ...
<< < 1 2 3 4 > >>