るりまサーチ (Ruby 2.4.0)

最速Rubyリファレンスマニュアル検索!
1件ヒット [1-1件を表示] (0.287秒)
トップページ > クラス:Numeric[x] > バージョン:2.4.0[x] > クエリ:_builtin[x] > クエリ:numeric[x] > クエリ:to_c[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

検索結果

Numeric#to_c -> Complex (105397.0)

自身を複素数 (Complex) に変換します。Complex(self, 0) を返します。

...lex(self, 0) を返します。

//emlist[例][ruby]{
1.to_c # => (1+0i)
-1.to_c # => (-1+0i)
1.0.to_c # => (1.0+0i)
Rational(1, 2).to_c # => ((1/2)+0i)
//}

Numeric
のサブクラスは、このメソッドを適切に再定義しなければなりません。...