るりまサーチ

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

別のキーワード

  1. _builtin typeerror
  2. sort typeerror
  3. dump typeerror
  4. $@ typeerror
  5. $~ typeerror

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Range#end -> object (18104.0)

終端の要素を返します。範囲オブジェクトが終端を含むかどうかは関係ありま せん。

終端の要素を返します。範囲オブジェクトが終端を含むかどうかは関係ありま
せん。

//emlist[例][ruby]{
(10..20).last # => 20
(10...20).last # => 20
//}

@see Range#begin

Range#last(n) -> [object] (3014.0)

最後の n 要素を返します。範囲内に要素が含まれない場合は空の配列を返します。

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

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

@raise...
...の数を指定した場合に発生します。

[注意] 引数を省略して実行した場合は、終端を含むかどうか
(Range#exclude_end? の戻り値)に関わらず終端の要素を返す事に注意し
てください。

//emlist[例][ruby]{
(10..20).last(3) # => [18, 19, 20]
(1...

Range#last -> object (3004.0)

終端の要素を返します。範囲オブジェクトが終端を含むかどうかは関係ありま せん。

終端の要素を返します。範囲オブジェクトが終端を含むかどうかは関係ありま
せん。

//emlist[例][ruby]{
(10..20).last # => 20
(10...20).last # => 20
//}

@see Range#begin

UnboundMethod#bind(obj) -> Method (43.0)

self を obj にバインドした Method オブジェクトを生成して返します。

...インスタンスのみです。

@raise TypeError objがbindできないオブジェクトである場合に発生します

//emlist[例][ruby]{
# クラスのインスタンスメソッドの UnboundMethod の場合
class Foo
def foo
"foo"
end

end


# UnboundMethod `m' を生成
p m = Foo...
...タンスをレシーバとする Method
class Bar < Foo
end

p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>


# モジュールのインスタンスメソッドの UnboundMethod の場合
module Foo
def foo
"foo"
end

end


# UnboundMethod `m' を生成
p m = Foo.instance_method(...
...:foo) # => #<UnboundMethod: Foo#foo>

# Foo をインクルードしたクラス Bar のインスタンスをレシーバと
# する Method オブジェクトを生成
class Bar
include Foo
end

p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>
//}...
...:foo) # => #<UnboundMethod: Foo#foo>

# Foo をインクルードしたクラス Bar のインスタンスをレシーバと
# する Method オブジェクトを生成
class Bar
include Foo
end

p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>
//}

@see UnboundMethod#bind_call...

Array#[](range) -> Array | nil (37.0)

Range オブジェクト range の範囲にある要素からなる部分配列を返します。 range の begin が自身の範囲外となる時は nil を返します。ただし、begin が配列の長さに等しいときは空の配列を返します。 range の begin が end より後にある場合には空の配列を返します。

...の配列を返します。
range の begin が end より後にある場合には空の配列を返します。

@param range 生成したい部分配列の範囲を Range オブジェクトで指定します。
range の begin や end の値が負の時には末尾からのインデ...
...ックスと見倣します。末尾
の要素が -1 番目になります。
end
の値が配列の範囲を越える時には、越えた分は無視されます。

//emlist[例][ruby]{
a = [ "a", "b", "c", "d", "e" ]
a[0..1] #=> ["a", "b"]
a[0...1] #=> ["a"]
a[0..-1]...
...#=> ["a", "b", "c", "d", "e"]
a[-2..-1] #=> ["d", "e"]
a[-2..4] #=> ["d", "e"] (start は末尾から -2 番目、end は先頭から (4+1) 番目となる。)
a[0..10] #=> ["a", "b", "c", "d", "e"]
a[10..11] #=> nil
a[2..1] #=> []
a[-1..-2] #=> []

# 特殊なケース。begin が自身の...

絞り込み条件を変える

Module#<(other) -> bool | nil (37.0)

比較演算子。self が other の子孫である場合、 true を返します。 self が other の先祖か同一のクラス/モジュールである場合、false を返します。

...m other 比較対象のモジュールやクラス

@raise TypeError other がクラスやモジュールではない場合に発生します。

//emlist[例][ruby]{
module Foo
end

class Bar
include Foo
end

class Baz < Bar
end

class Qux
end

p Bar < Foo # => true
p Baz < Bar # => true
p Ba...
...z < Foo # => true
p Baz < Qux # => nil
p Baz > Qux # => nil

p Foo < Object.new # => in `<': compared with non class/module (TypeError)
//}...

Object#initialize_copy(obj) -> object (31.0)

(拡張ライブラリによる) ユーザ定義クラスのオブジェクトコピーの初期化メソッド。

...を返すだけのメソッドです。

initialize_copy という名前のメソッドは
自動的に private に設定されます。

@raise TypeError レシーバが freeze されているか、obj のクラスがレシーバ
のクラスと異なる場合に発生します。
@see Object#cl...
...cessor :foo
def bar
:bar
end

end


def check(obj)
puts "instance variables: #{obj.inspect}"
puts "tainted?: #{obj.tainted?}"
print "singleton methods: "
begin
p obj.bar
rescue NameError
p $!
end

end


obj.foo = 1
obj.taint

check Object.new.send(:initialize_copy, obj)...
...class <<obj
attr_accessor :foo
def bar
:bar
end

end


def check(obj)
puts "instance variables: #{obj.inspect}"
print "singleton methods: "
begin
p obj.bar
rescue NameError
p $!
end

end


obj.foo = 1

check Object.new.send(:initialize_copy, obj)
#=> instance variabl...

Module#<=(other) -> bool | nil (25.0)

比較演算子。self が other の子孫であるか、self と other が 同一クラスである場合、 true を返します。 self が other の先祖である場合、false を返します。

...r 比較対象のモジュールやクラス

@raise TypeError other がクラスやモジュールではない場合に発生します。

@see Module#<

//emlist[例][ruby]{
module Foo; end
module Bar
include Foo
end

module Baz
prepend Foo
end


Bar.ancestors # => [Bar, Foo]
Foo <= Bar # => fal...

Module#>(other) -> bool | nil (25.0)

比較演算子。 self が other の先祖である場合、true を返します。 self が other の子孫か同一クラスである場合、false を返します。

...のモジュールやクラス

@raise TypeError other がクラスやモジュールではない場合に発生します。

@see Module#<

//emlist[例][ruby]{
module Awesome; end
module Included
include Awesome
end

module Prepended
prepend Awesome
end


Included.ancestors # => [Included, Aweso...
...me]
Awesome > Included # => true
Included > Awesome # => false

Prepended.ancestors # => [Awesome, Prepended]
Awesome > Prepended # => true
Prepended > Awesome # => false

Awesome > Awesome # => false
Awesome > Object # => nil
//}...
<< 1 2 3 ... > >>