るりまサーチ

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

別のキーワード

  1. objectspace each_object
  2. _builtin each_object
  3. object send
  4. object to_enum
  5. object enum_for

検索結果

<< 1 2 3 ... > >>

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

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

...較では
nil
を返します。

@param 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 Baz < Foo # => true
p Baz < Qux # => nil
p Baz > Qux # => nil

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

Object#<=>(other) -> 0 | nil (15241.0)

self === other である場合に 0 を返します。そうでない場合には nil を返します。

...self === other である場合に 0 を返します。そうでない場合には nil を返します。

//emlist[例][ruby]{
a = Object.new
b = Object.new
a <=> a # => 0
a <=> b # => nil
//}

@see Object#===...

Object#enum_for(method = :each, *args) -> Enumerator (9012.0)

Enumerator.new(self, method, *args) を返します。

...s an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは...
...ッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator:...

Object#enum_for(method = :each, *args) {|*args| ... } -> Enumerator (9012.0)

Enumerator.new(self, method, *args) を返します。

...s an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは...
...ッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator:...

Object#to_enum(method = :each, *args) -> Enumerator (9012.0)

Enumerator.new(self, method, *args) を返します。

...s an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは...
...ッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator:...

絞り込み条件を変える

Object#to_enum(method = :each, *args) {|*args| ... } -> Enumerator (9012.0)

Enumerator.new(self, method, *args) を返します。

...s an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}

//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} is negative!" if n < 0
unless block_given?
# __method__ はここでは...
...ッドが nil でなければ size * n を返す。
sz = size
sz * n if sz
end
end
each do |*val|
n.times { yield *val }
end
end
end

%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator:...

Module#<=>(other) -> Integer | nil (6243.0)

self と other の継承関係を比較します。

...では
nil
を返します。

other がクラスやモジュールでなければ
nil
を返します。

@param other 比較対象のクラスやモジュール

//emlist[例][ruby]{
module Foo
end
class Bar
include Foo
end
class Baz < Bar
end
class Qux
end
p Bar <=> Foo # => -1
p Baz <=> Ba...
...r # => -1
p Baz <=> Foo # => -1
p Baz <=> Qux # => nil
p Qux <=> Baz # => nil

p Baz <=> Object.new # => nil
//}...

Date#<=>(other) -> -1 | 0 | 1 | nil (6219.0)

二つの日付を比較します。 同じ日付なら 0 を、self が other よりあとの日付なら 1 を、 その逆なら -1 を返します。

...いので nil を返します。

//emlist[][ruby]{
require "date"

p Date.new(2001, 2, 3) <=> Date.new(2001, 2, 4) # => -1
p Date.new(2001, 2, 3) <=> Date.new(2001, 2, 3) # => 0
p Date.new(2001, 2, 3) <=> Date.new(2001, 2, 2) # => 1
p Date.new(2001, 2, 3) <=> Object.new # => nil
p Date.ne...
...w(2001, 2, 3) <=> Rational(4903887, 2) # => 0
//}

@param other 日付オブジェクトまたは数値...

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

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

...

継承関係にないクラス同士の比較では
nil
を返します。

@param other 比較対象のモジュールやクラス

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

@see Module#<

//emlist[例][ruby]{
module Foo; end
module Bar
inc...
...lude Foo
end
module Baz
prepend Foo
end

Bar.ancestors # => [Bar, Foo]
Foo <= Bar # => false
Bar <= Foo # => true

Baz.ancestors # => [Foo, Baz]
Foo <= Baz # => false
Baz <= Foo # => true

Foo <= Foo # => true
Foo <= Object # => nil
//}...

BasicObject#! -> bool (3024.0)

オブジェクトを真偽値として評価し、その論理否定を返します。

...elf が nil または false であれば真を、さもなくば偽を返します。
主に論理式の評価に伴って副作用を引き起こすことを目的に
再定義するものと想定されています。

このメソッドを再定義しても Ruby の制御式において nil や f...
...corder < BasicObject
def initialize
@count = 0
end
attr_reader :count

def !
@count += 1
super
end
end

recorder = NegationRecorder.new
!recorder
!!!!!!!recorder
puts 'hoge' if !recorder

puts recorder.count #=> 3
//}

//emlist[例][ruby]{
class AnotherFalse < BasicObject
de...

絞り込み条件を変える

<< 1 2 3 ... > >>