るりまサーチ (Ruby 2.5.0)

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

別のキーワード

  1. _builtin to_s
  2. openssl to_der
  3. openssl to_s
  4. _builtin to_a
  5. openssl to_pem

クラス

キーワード

検索結果

String#to_str -> String (45379.0)

self を返します。

self を返します。

//emlist[例][ruby]{
p "str".to_s # => "str"
p "str".to_str # => "str"
//}

このメソッドは、文字列を他のクラスのインスタンスと混ぜて処理したいときに有効です。
例えば返り値が文字列か nil であるメソッド some_method があるとき、
to_s メソッドを使うと以下のように統一的に処理できます。

//emlist[例][ruby]{
# some_method(5).downcase だと返り値が nil のときに
# エラーになるので to_s をはさむ
p some_...

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

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

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

other が文字列でない場合、
other.to_str と other.<=> が定義されていれば
0 - (other <=> self) の結果を返します。
そうでなければ nil を返します。

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

//emlist[例][ruby]{
p "aaa" <...

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

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

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

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

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

//emlist[例][ruby]{
stringlike = Object.new

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

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

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

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

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

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

//emlist[例][ruby]{
stringlike = Object.new

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

String#to_s -> String (79.0)

self を返します。

self を返します。

//emlist[例][ruby]{
p "str".to_s # => "str"
p "str".to_str # => "str"
//}

このメソッドは、文字列を他のクラスのインスタンスと混ぜて処理したいときに有効です。
例えば返り値が文字列か nil であるメソッド some_method があるとき、
to_s メソッドを使うと以下のように統一的に処理できます。

//emlist[例][ruby]{
# some_method(5).downcase だと返り値が nil のときに
# エラーになるので to_s をはさむ
p some_...

絞り込み条件を変える