検索結果
-
Integer
. try _ convert(obj) -> Integer | nil (39272.0) -
obj を Integer に変換しようと試みます。変換には Object#to_int メソッドが使われます。
...obj を Integer に変換しようと試みます。変換には Object#to_int
メソッドが使われます。
Integer ならそのままobjを返します。
そうでなければ obj.to_int の結果を返すか、nil が返されます。
@param obj 変換する任意のオブジェクト......@return Integer または nil
@raise TypeError to_int が Integer を返さなかった場合に発生します。
//emlist[例][ruby]{
Integer.try_convert(1) # => 1
Integer.try_convert(1.25) # => 1
Integer.try_convert([]) # => nil
//}... -
NEWS for Ruby 3
. 1 . 0 (36.0) -
NEWS for Ruby 3.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...リ秒で返します。 10917
* GC.total_time が計測された時間をナノ秒で返します。 10917
* Integer
* 新規メソッド
* Integer.try_convert が追加されました。 15211
* Kernel
* 変更されたメソッド
* Kernel#load が第2引数にモ......り厳密に整数に変換されるようになりました。
//emlist[Time.new][ruby]{
Time.new(2021, 12, 25, "+07:30")
#=> invalid value for Integer(): "+07:30" (ArgumentError)
//}
* Ruby 3.0 以前では、予期しない結果の 2021-12-25 07:00:00 が返されました。 2021-12-25......s://github.com/ruby/rbs/pull/844
//emlist{
# `T` must be compatible with the `_Output` interface.
# `PrettyPrint[String]` is ok, but `PrettyPrint[Integer]` is a type error.
class PrettyPrint[T < _Output]
interface _Output
def <<: (String) -> void
end
attr_reader output: T
def initiali...