るりまサーチ

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

別のキーワード

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

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Numeric#to_int -> Integer (32337.0)

self.to_i と同じです。

...self.to_i と同じです。

//emlist[例][ruby]{
(2+0i).to_int # => 2
Rational(3).to_int # => 3
//}...

Object#to_int -> Integer (32309.0)

オブジェクトの Integer への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。

...オブジェクトの Integer への暗黙の変換が必要なときに内部で呼ばれます。
デフォルトでは定義されていません。

説明のためここに記載してありますが、
このメソッドは実際には Object クラスには定義されていません。
...
...が使われるすべての場面で代置可能であるような、
* 整数そのものとみなせるようなもの
という厳しいものになっています。

//emlist[][ruby]{
class Foo
def to_int
1
end
end

ary = [:a, :b, :c]
p(ary[Foo.new]) # => :b
//}

@see Kernel.#Integer...

Integer#to_int -> self (29210.0)

self を返します。

...self を返します。

//emlist[][ruby]{
10.to_i # => 10
//}...

Kernel.#Integer(arg, base = 0) -> Integer (14244.0)

引数を整数(Fixnum,Bignum)に変換した結果を返します。

...引数を整数(Fixnum,Bignum)に変換した結果を返します。

引数が数値の場合は直接変換し(小数点以下切り落とし)、
文字列の場合は、進数を表す接頭辞を含む整数表現とみなせる文字列のみ
変換します。

数値と文字列以外...
...のオブジェクトに対しては arg.to_int, arg.to_i
この順に使用して変換します。

@param arg 変換対象のオブジェクトです。

@param base 基数として0か2から36の整数を指定します(引数argに文字列を指
定した場合のみ)。省略...
...数) です。


@raise ArgumentError 整数と見なせない文字列を引数に指定した場合に発生します。
@raise TypeError メソッド to_int, to_i を持たないオブジェクトを引数に指定したか、to_int, to_i
が整数(Integerのサブクラス)を返...

Kernel.#Integer(arg, base = 0, exception: true) -> Integer | nil (14244.0)

引数を整数(Fixnum,Bignum)に変換した結果を返します。

...引数を整数(Fixnum,Bignum)に変換した結果を返します。

引数が数値の場合は直接変換し(小数点以下切り落とし)、
文字列の場合は、進数を表す接頭辞を含む整数表現とみなせる文字列のみ
変換します。

数値と文字列以外...
...のオブジェクトに対しては arg.to_int, arg.to_i
この順に使用して変換します。

@param arg 変換対象のオブジェクトです。

@param base 基数として0か2から36の整数を指定します(引数argに文字列を指
定した場合のみ)。省略...
...exception false を指定すると、変換できなかった場合、
例外を発生する代わりに nil を返します。

@raise ArgumentError 整数と見なせない文字列を引数に指定した場合に発生します。
@raise TypeError メソッド to_int, to_i...

絞り込み条件を変える

Object#public_method(name) -> Method (14114.0)

オブジェクトの public メソッド name をオブジェクト化した Method オブジェクトを返します。

...トの public メソッド name をオブジェクト化した
Method オブジェクトを返します。

@param name メソッド名を Symbol または String で指定します。
@raise NameError 定義されていないメソッド名や、
protected メソッド名、 private メソ...
...ッド名を引数として与えると発生します。

//emlist[][ruby]{
1.public_method(:to_int) #=> #<Method: Integer#to_int>
1.public_method(:p) # method `p' for class `Integer' is private (NameError)
//}

@see Object#method,Object#public_send,Module#public_instance_method...

Integer#to_i -> self (14110.0)

self を返します。

...self を返します。

//emlist[][ruby]{
10.to_i # => 10
//}...

Array#combination(n) -> Enumerator (14108.0)

サイズ n の組み合わせをすべて生成し、それを引数としてブロックを実行します。

...場合は to_int メソッドによる暗
黙の型変換を試みます。

@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。

//emlist[例][ruby]{
a = [1, 2, 3, 4]
a.combination(1).to_...
...2],[3],[4]]
a.combination(2).to_a #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
a.combination(3).to_a #=> [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
a.combination(4).to_a #=> [[1,2,3,4]]
a.combination(0).to_a #=> [[]]: one combination of length 0
a.combination(5).to_a #=> [] : no combinations of length 5
/...
...た配列の各要素を引数としてブロックを実
行して self を返します。

//emlist[例][ruby]{
a = [1, 2, 3, 4]
result = []
a.combination(2) {|e| result << e} # => [1,2,3,4]
result #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
//}

@see Array#permutation, Array#repeated_combination...

Array#combination(n) {|c| block } -> self (14108.0)

サイズ n の組み合わせをすべて生成し、それを引数としてブロックを実行します。

...場合は to_int メソッドによる暗
黙の型変換を試みます。

@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。

//emlist[例][ruby]{
a = [1, 2, 3, 4]
a.combination(1).to_...
...2],[3],[4]]
a.combination(2).to_a #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
a.combination(3).to_a #=> [[1,2,3],[1,2,4],[1,3,4],[2,3,4]]
a.combination(4).to_a #=> [[1,2,3,4]]
a.combination(0).to_a #=> [[]]: one combination of length 0
a.combination(5).to_a #=> [] : no combinations of length 5
/...
...た配列の各要素を引数としてブロックを実
行して self を返します。

//emlist[例][ruby]{
a = [1, 2, 3, 4]
result = []
a.combination(2) {|e| result << e} # => [1,2,3,4]
result #=> [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
//}

@see Array#permutation, Array#repeated_combination...

Array#first(n) -> Array (14108.0)

先頭の n 要素を配列で返します。n は 0 以上でなければなりません。

... to_int メソッドによる暗
黙の型変換を試みます。

@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)オブジェクトを
指定した場合に発生します。

@raise ArgumentError n が負値の場合発生します。

//emli...
...st[例][ruby]{
ary = [0, 1, 2]
p ary.first(0)
p ary.first(1)
p ary.first(2)
p ary.first(3)
p ary.first(4)
# => []
# [0]
# [0, 1]
# [0, 1, 2]
# [0, 1, 2]
//}

@see Array#last...

絞り込み条件を変える

Array#insert(nth, *val) -> self (14108.0)

インデックス nth の要素の直前(nth が負の場合は直後)に第 2 引数以降の値を挿入します。 引数 val を一つも指定しなければ何もしません。

...
整数以外のオブジェクトを指定した場合は to_int メソッドによる
暗黙の型変換を試みます。

@param val 自身に挿入するオブジェクトを指定します。

@raise TypeError 引数に整数以外の(暗黙の型変換が行えない)...
...オブジェクトを
指定した場合に発生します。

//emlist[例][ruby]{
ary = [1, 2, 3]
ary.insert(2, "a", "b")
p ary # => [1, 2, "a", "b", 3]
ary.insert(-2, "X")
p ary # => [1, 2, "a", "b", "X", 3]
//}...
<< 1 2 3 ... > >>