るりまサーチ

最速Rubyリファレンスマニュアル検索!
365件ヒット [301-365件を表示] (0.068秒)
トップページ > クエリ:b[x] > クエリ:upcase[x]

別のキーワード

  1. string b
  2. _builtin b
  3. b string
  4. b
  5. b _builtin

ライブラリ

クラス

モジュール

検索結果

<< < ... 2 3 4 >>

String (144.0)

文字列のクラスです。 ヌル文字を含む任意のバイト列を扱うことができます。 文字列の長さにはメモリ容量以外の制限はありません。

...テラルを使って生成します。
以下に文字列リテラルの例をいくつか示します。

//emlist[文字列リテラルの例][ruby]{
'str\\ing' # シングルクオート文字列 (エスケープシーケンスがほぼ無効)
"string\n" # ダブルクオート文字列 (エ...
...、ダブルクオートとの併用も可能
<<~End
この行のインデントは無視される
End
//}

===[a:mutable] 破壊的な変更

Ruby の String クラスは mutable です。
つまり、オブジェクト自体を破壊的に変更できます。

「破壊的な変更」とは、...
...字へ変更する
String#upcase! メソッドの使用例を以下に示します。

//emlist[例:String#upcase!][ruby]{
a = "string"
b
= a
a.upcase!
p a # => "STRING"
p b # => "STRING"
//}

この例では、a に対してメソッドを呼んだにも関わらず b も変更されていま...

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

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

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

//emlist[例][ruby]{
hash = {}
p hash.to_h # => {}
p hash.to_h == hash # => true

class MyHash < Hash;end
my_hash = MyHash.new
p my_hash.to_h # => {}
p my_...
...sh
//}

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

@see Enumerable#map...

String#eql?(other) -> bool (118.0)

文字列の内容が文字列 other の内容と等しいときに true を返します。 等しくなければ false を返します。

...
同一のオブジェクトであるかどうかを判定したいときは
Object#equal? を使ってください。

アルファベットの大文字小文字を無視して比較したい場合は、String#upcase,
String#downcase で大文字小文字を揃えてから比較してくださ...
...

Hash クラス内での比較に使われます。

@param other 任意のオブジェクト
@return true か false

//emlist[例][ruby]{
p "string".eql?("string") # => true
p "string".eql?("STRING") # => false
p "string".eql?("") # => false
p "".eql?("string") # => f...
...ql?("str" + "ing") # => true (内容が同じなら true)
p "string".eql?("stringX".chop) # => true (内容が同じなら true)

p "string".upcase.eql?("String".upcase) # => true
p "string".downcase.eql?("String".downcase) # => true
//}

@see Hash, String#<=>, String#casecmp, String#==...

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

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

...emlist[例][ruby]{
h = { "cat" => "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"]
//}

@s...

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

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

...emlist[例][ruby]{
h = { "cat" => "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"]
//}

@s...

絞り込み条件を変える

OpenStruct#to_h -> { Symbol => object } (106.0)

self を各要素の名前をキー(Symbol)、要素が値のハッシュに変換して返 します。

...(Symbol)、要素が値のハッシュに変換して返
します。

ブロックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。

//emlist[例][ruby]{
require 'ostruct'
data = OpenStruct.new("country" => "Australia", :capital => "Canberra"...
...)
data.to_h # => {:country => "Australia", :capital => "Canberra" }
data.to_h {|name, value| [name.to_s, value.upcase] }
# => {"country" => "AUSTRALIA", "capital" => "CANBERRA" }
//}...

OpenStruct#to_h {|name, value| block } -> Hash (106.0)

self を各要素の名前をキー(Symbol)、要素が値のハッシュに変換して返 します。

...(Symbol)、要素が値のハッシュに変換して返
します。

ブロックを指定すると各ペアでブロックを呼び出し、
その結果をペアとして使います。

//emlist[例][ruby]{
require 'ostruct'
data = OpenStruct.new("country" => "Australia", :capital => "Canberra"...
...)
data.to_h # => {:country => "Australia", :capital => "Canberra" }
data.to_h {|name, value| [name.to_s, value.upcase] }
# => {"country" => "AUSTRALIA", "capital" => "CANBERRA" }
//}...

リテラル (102.0)

リテラル * num * string * backslash * exp * char * command * here * regexp * array * hash * range * symbol * percent

...リテラル
* num
* string
* backslash
* exp
* char
* command
* here
* regexp
* array
* hash
* range
* symbol
* percent

数字の1や文字列"hello world"のようにRubyのプログラムの中に直接
記述できる値の事をリテラルといいます。

===[a:n...
...小数点数は許されなくなりました。0.1 と書く必
要があります。

: 1.2e-3

浮動小数点数
: 0xffff

16進整数
: 0b1011

2進整数
: 0377
: 0o377

8進整数
: 42r
: 3.14r

有理数。
ただし、誤解を招く恐れがあるため、6.022e+23r のよう...
...ruby]{
# 式の中に開始ラベルを書く
# method の第二引数には " ヒアドキュメント\n" が渡される
method(arg1, <<LABEL, arg2)
ヒアドキュメント
LABEL

# ヒアドキュメントをレシーバにメソッドを呼ぶ
p <<LABEL.upcase
the lower case string
LABE...

Hash#to_h -> self | Hash (18.0)

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

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

//emlist[例][ruby]{
hash = {}
p hash.to_h # => {}
p hash.to_h == hash # => true

class MyHash < Hash;end
my_hash = MyHash.new
p my_hash.to_h # => {}
p my_...
...sh
//}

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

@see Enumerable#map...
<< < ... 2 3 4 >>