るりまサーチ

最速Rubyリファレンスマニュアル検索!
317件ヒット [1-100件を表示] (0.045秒)
トップページ > クエリ:Ruby[x] > クエリ:@[x] > クラス:String[x] > クエリ:==[x]

別のキーワード

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

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

String#==(other) -> bool (18149.0)

other が文字列の場合、String#eql? と同様に文字列の内容を比較します。

...合、String#eql? と同様に文字列の内容を比較します。

other が文字列でない場合、
other.to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false を返します。

@
param...
...
@
return true か false

//emlist[例][ruby]{
string
like = Object.new

def stringlike.==(other)
"string" == other
end

p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> false

def stringlike.to_str
raise
end

p "string".eql?(stringlike) #=> false
p "string" == stringl...
...ike #=> true
//}

@
see String#eql?...

String#===(other) -> bool (9249.0)

other が文字列の場合、String#eql? と同様に文字列の内容を比較します。

...合、String#eql? と同様に文字列の内容を比較します。

other が文字列でない場合、
other.to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false を返します。

@
param...
...
@
return true か false

//emlist[例][ruby]{
string
like = Object.new

def stringlike.==(other)
"string" == other
end

p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> false

def stringlike.to_str
raise
end

p "string".eql?(stringlike) #=> false
p "string" == stringl...
...ike #=> true
//}

@
see String#eql?...

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

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

...eze されていない場合は self を返します。

//emlist[例][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 = +original_text
unfrozen_text.frozen? # => false
original_text == unfrozen_text # => true
original_text.equal?(unfrozen_text) # => false
//}

@
see String#-@...

String#-@ -> String | self (6125.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) # => fa...
...lse

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

@
see String#+@...

String#dedup -> String | self (3025.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) # => fa...
...lse

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

@
see String#+@...

絞り込み条件を変える

String#unpack(template) -> Array (703.0)

Array#pack で生成された文字列を テンプレート文字列 template にしたがってアンパックし、 それらの要素を含む配列を返します。

...アンパックし、
それらの要素を含む配列を返します。

@
param template pack テンプレート文字列
@
return オブジェクトの配列


以下にあげるものは、Array#pack、String#unpack
のテンプレート文字の一覧です。テンプレート文...
...されます。
また、`#' から改行あるいはテンプレート文字列の最後まではコメントとみな
され無視されます。

==
= 整数のテンプレート文字のシステム依存性

各テンプレート文字の説明の中で、
short や long はシステムによら...
...明中、Array#pack と String#unpack で違いのあるものは `/' で区切って
「Array#pack の説明 / String#unpack の説明」としています。

: a

ASCII文字列(ヌル文字を詰める/後続するヌル文字やスペースを残す)
//emlist[][ruby]{
["abc"].pack("a") # =...
...ックし、
それらの要素を含む配列を返します。

@
param template pack テンプレート文字列
@
return オブジェクトの配列


以下にあげるものは、Array#pack、String#unpack、String#unpack1
のテンプレート文字の一覧です。テンプレ...

String#split(sep = $;, limit = 0) -> [String] (103.0)

第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。 ブロックを指定すると、配列を返す代わりに分割した文字列で ブロックを呼び出します。

...分割する
: limit == 0
分割個数制限はなしで、配列末尾の空文字列を取り除く
: limit < 0
分割個数の制限はなし

@
param sep 文字列を分割するときのセパレータのパターン
@
param limit 分割する最大個数

@
return ブロック...
...を渡した場合は self、ブロックなしの場合は配列

//emlist[例][ruby]{
p " a \t b \n c".split(/\s+/) # => ["", "a", "b", "c"]

p " a \t b \n c".split(nil) # => ["a", "b", "c"]
p " a \t b \n c".split(' ') # => ["a", "b", "c"] # split(nil) と同じ
p " a \t b \n...
... == -1 の場合と比べると、結果の配列末尾に含まれる空文字列が取り除かれている。
p " a b ".split(' ', 0) # => ["a", "b"]

# limit == 1 の場合は元の文字列がそのまま含まれる。
p " a b ".split(' ', 1) # => [" a b "]
//}

@
see String...

String#split(sep = $;, limit = 0) {|s| ... } -> self (103.0)

第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。 ブロックを指定すると、配列を返す代わりに分割した文字列で ブロックを呼び出します。

...分割する
: limit == 0
分割個数制限はなしで、配列末尾の空文字列を取り除く
: limit < 0
分割個数の制限はなし

@
param sep 文字列を分割するときのセパレータのパターン
@
param limit 分割する最大個数

@
return ブロック...
...を渡した場合は self、ブロックなしの場合は配列

//emlist[例][ruby]{
p " a \t b \n c".split(/\s+/) # => ["", "a", "b", "c"]

p " a \t b \n c".split(nil) # => ["a", "b", "c"]
p " a \t b \n c".split(' ') # => ["a", "b", "c"] # split(nil) と同じ
p " a \t b \n...
... == -1 の場合と比べると、結果の配列末尾に含まれる空文字列が取り除かれている。
p " a b ".split(' ', 0) # => ["a", "b"]

# limit == 1 の場合は元の文字列がそのまま含まれる。
p " a b ".split(' ', 1) # => [" a b "]
//}

@
see String...

String#split(sep = $;, limit = 0) -> [String] (97.0)

第 1 引数 sep で指定されたセパレータによって文字列を limit 個まで分割し、 結果を文字列の配列で返します。

...
: limit == 0
分割個数制限はなしで、配列末尾の空文字列を取り除く
: limit < 0
分割個数の制限はなし

@
param sep 文字列を分割するときのセパレータのパターン
@
param limit 分割する最大個数


//emlist[例][ruby]{
p " a...
...][ruby]{
p '1-10,20'.split(/([-,])/) # => ["1", "-", "10", ",", "20"]
//}

//emlist[正規表現が空文字列にマッチする場合は 1 文字に分割][ruby]{
p 'hi there'.split(/\s*/).join(':') # => "h:i:t:h:e:r:e"
//}

//emlist[文字列全体を 1 文字ずつに分割する例][ruby]{
p...
... == -1 の場合と比べると、結果の配列末尾に含まれる空文字列が取り除かれている。
p " a b ".split(' ', 0) # => ["a", "b"]

# limit == 1 の場合は元の文字列がそのまま含まれる。
p " a b ".split(' ', 1) # => [" a b "]
//}

@
see String...

String.new(string = "") -> String (43.0)

string と同じ内容の新しい文字列を作成して返します。 引数を省略した場合は空文字列を生成して返します。

...
string
と同じ内容の新しい文字列を作成して返します。
引数を省略した場合は空文字列を生成して返します。

@
param string 文字列
@
param encoding 作成する文字列のエンコーディングを文字列か
Encoding オブジェクト...
...合、引数stringのバイト数が127未満であれば127、
それ以上であればstring.bytesizeになります。
@
return 引数 string と同じ内容の文字列オブジェクト

//emlist[例][ruby]{
text = "hoge".encode("EUC-JP")
no_option = String.new(text)...
...# => "hoge"
no_option.encoding == Encoding::EUC_JP # => true
with_encoding = String.new(text, encoding: "UTF-8") # => "hoge"
with_encoding.encoding == Encoding::UTF_8 # => true
String
.new("test", encoding: "UTF-8", capacity: 100_000) # =>...

絞り込み条件を変える

String.new(string = "", encoding: string.encoding, capacity: 127) -> String (43.0)

string と同じ内容の新しい文字列を作成して返します。 引数を省略した場合は空文字列を生成して返します。

...
string
と同じ内容の新しい文字列を作成して返します。
引数を省略した場合は空文字列を生成して返します。

@
param string 文字列
@
param encoding 作成する文字列のエンコーディングを文字列か
Encoding オブジェクト...
...合、引数stringのバイト数が127未満であれば127、
それ以上であればstring.bytesizeになります。
@
return 引数 string と同じ内容の文字列オブジェクト

//emlist[例][ruby]{
text = "hoge".encode("EUC-JP")
no_option = String.new(text)...
...# => "hoge"
no_option.encoding == Encoding::EUC_JP # => true
with_encoding = String.new(text, encoding: "UTF-8") # => "hoge"
with_encoding.encoding == Encoding::UTF_8 # => true
String
.new("test", encoding: "UTF-8", capacity: 100_000) # =>...

String.new(string = "", encoding: string.encoding, capacity: 63) -> String (43.0)

string と同じ内容の新しい文字列を作成して返します。 引数を省略した場合は空文字列を生成して返します。

...
string
と同じ内容の新しい文字列を作成して返します。
引数を省略した場合は空文字列を生成して返します。

@
param string 文字列
@
param encoding 作成する文字列のエンコーディングを文字列か
Encoding オブジェクト...
...合、引数stringのバイト数が127未満であれば127、
それ以上であればstring.bytesizeになります。
@
return 引数 string と同じ内容の文字列オブジェクト

//emlist[例][ruby]{
text = "hoge".encode("EUC-JP")
no_option = String.new(text)...
...# => "hoge"
no_option.encoding == Encoding::EUC_JP # => true
with_encoding = String.new(text, encoding: "UTF-8") # => "hoge"
with_encoding.encoding == Encoding::UTF_8 # => true
String
.new("test", encoding: "UTF-8", capacity: 100_000) # =>...

String.new(string = "", encoding: string.encoding, capacity: string.bytesize) -> String (43.0)

string と同じ内容の新しい文字列を作成して返します。 引数を省略した場合は空文字列を生成して返します。

...
string
と同じ内容の新しい文字列を作成して返します。
引数を省略した場合は空文字列を生成して返します。

@
param string 文字列
@
param encoding 作成する文字列のエンコーディングを文字列か
Encoding オブジェクト...
...合、引数stringのバイト数が127未満であれば127、
それ以上であればstring.bytesizeになります。
@
return 引数 string と同じ内容の文字列オブジェクト

//emlist[例][ruby]{
text = "hoge".encode("EUC-JP")
no_option = String.new(text)...
...# => "hoge"
no_option.encoding == Encoding::EUC_JP # => true
with_encoding = String.new(text, encoding: "UTF-8") # => "hoge"
with_encoding.encoding == Encoding::UTF_8 # => true
String
.new("test", encoding: "UTF-8", capacity: 100_000) # =>...
<< 1 2 3 ... > >>