るりまサーチ

最速Rubyリファレンスマニュアル検索!
2131件ヒット [1201-1300件を表示] (0.101秒)

別のキーワード

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

ライブラリ

キーワード

検索結果

<< < ... 11 12 13 14 15 ... > >>

String#gsub!(pattern, hash) -> self | nil (3120.0)

文字列中の pattern にマッチした部分をキーにして hash を引いた値へ破壊的に置き換えます。

...ます。

@param pattern 置き換える文字列のパターン
@param hash 置き換える文字列を与えるハッシュ

//emlist[例][ruby]{
hash = {'b'=>'B', 'c'=>'C'}
str = "abcabc"
str.gsub!(/[bc]/){hash[$&]}
p str #=> "aBCaBC"

str = "abcabc"
str.gsub!(/[bc]/, hash)
p str...

String#hex -> Integer (3120.0)

文字列に 16 進数で数値が表現されていると解釈して整数に変換します。 接頭辞 "0x", "0X" とアンダースコアは無視されます。 文字列が [_0-9a-fA-F] 以外の文字を含むときはその文字以降を無視します。

...返します。

//emlist[例][ruby]{
p "10".hex # => 16
p "ff".hex # => 255
p "0x10".hex # => 16
p "-0x10".hex # => -16

p "xyz".hex # => 0
p "10z".hex # => 16
p "1_0".hex # => 16

p "".hex # => 0
//}

@see String#oct, String#to_i, String#to_f,
Kernel.#Integer, Kernel.#Float...
...このメソッドの逆に数値を文字列に変換するには
Kernel.#sprintf, String#%,
I
nteger#to_s
などを使ってください。...

String#sub!(pattern) {|matched| .... } -> self | nil (3118.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#prepend(*arguments) -> String (3116.0)

複数の文字列を先頭に破壊的に追加します。

...複数の文字列を先頭に破壊的に追加します。

@param arguments 追加したい文字列を指定します。

//emlist[例][ruby]{
a = "!!!"
a.prepend # => "!!!"
a # => "!!!"

a = "!!!"
a.prepend "hello ", "world" # => "hello world!!!"
a # => "hello...

String#prepend(other_str) -> String (3116.0)

文字列 other_str を先頭に破壊的に追加します。

...文字列 other_str を先頭に破壊的に追加します。

@param other_str 追加したい文字列を指定します。

//emlist[例][ruby]{
a = "world"
a.prepend("hello ") # => "hello world"
a # => "hello world"
//}...

絞り込み条件を変える

String#*(times) -> String (3114.0)

文字列の内容を times 回だけ繰り返した新しい文字列を作成して返します。

...の内容を times 回だけ繰り返した新しい文字列を作成して返します。

@param times 整数
@return self を times 回繰り返した新しい文字列

@raise ArgumentError 引数に負数を指定したときに発生します。

//emlist[例][ruby]{
p "str" * 3...

String#+(other) -> String (3114.0)

文字列と other を連結した新しい文字列を返します。

...er を連結した新しい文字列を返します。

@param other 文字列
@return self と other を連結した文字列

//emlist[例][ruby]{
p "str" + "ing" # => "string"

a = "abc"
b = "def"
p a + b # => "abcdef"
p a # => "abc" (変化なし)
p b # => "def"
//}...

String#+@ -> String | self (3114.0)

self が freeze されている文字列の場合、元の文字列の複製を返します。 freeze されていない場合は self を返します。

...ist[例][ruby]{
# frozen_string_literal: false

original_text = "text"
unfrozen_text = +original_text
unfrozen_text.frozen? # => false
original_text == unfrozen_text # => true
original_text.equal?(unfrozen_text) # => true

original_text = "text".freeze
unfrozen_text = +origi...
...nal_text
unfrozen_text.frozen? # => false
original_text == unfrozen_text # => true
original_text.equal?(unfrozen_text) # => false
//}

@see String#-@...

String#-@ -> String | self (3114.0)

self が freeze されている文字列の場合、self を返します。 freeze されていない場合は元の文字列の freeze された (できる限り既存の) 複製を返します。

...//emlist[例][ruby]{
# frozen_string_literal: false

original_text = "text"
frozen_text = -original_text
frozen_text.frozen? # => true
original_text == frozen_text # => true
original_text.equal?(frozen_text) # => false

original_text = "text".freeze
frozen_text = -original_t...
...ext
frozen_text.frozen? # => true
original_text == frozen_text # => true
original_text.equal?(frozen_text) # => true
//}

@see String#+@...

String#<=>(other) -> -1 | 0 | 1 | nil (3114.0)

self と other を ASCII コード順で比較して、 self が大きい時には 1、等しい時には 0、小さい時には -1 を返します。 このメソッドは Comparable モジュールのメソッドを実装するために使われます。

...self と other を ASCII コード順で比較して、
self が大きい時には 1、等しい時には 0、小さい時には -1 を返します。
このメソッドは Comparable モジュールのメソッドを実装するために使われます。

other が文字列でない場合、
othe...
...nil を返します。

@param other 文字列
@return 比較結果の整数か nil

//emlist[例][ruby]{
p "aaa" <=> "xxx" # => -1
p "aaa" <=> "aaa" # => 0
p "xxx" <=> "aaa" # => 1

p "string" <=> "stringAA" # => -1
p "string" <=> "string" # => 0
p "stringAA" <=> "string" # =...

絞り込み条件を変える

<< < ... 11 12 13 14 15 ... > >>