るりまサーチ

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

別のキーワード

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

ライブラリ

キーワード

検索結果

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

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

...list[例][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)
//...

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

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

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

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

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

Module#undef_method(*name) -> self (8026.0)

このモジュールのインスタンスメソッド name を未定義にします。

...def ok
puts 'A'
end
end
class B < A
def ok
puts 'B'
end
end

B.new.ok # => B

# undef_method の場合はスーパークラスに同名のメソッドがあっても
# その呼び出しはエラーになる
class B
undef_method :ok
end
B.new.ok # => NameError

# remove_method...
...
# それが呼ばれる
class B
remove_method :ok
end
B.new.ok # => A
//}

また、undef 文と undef_method の違いは、
メソッド名を String または Symbol で与えられることです。

//emlist[例][ruby]{
module
M1
def foo
end
def self.moo
undef foo
end
end
M1...
....instance_methods false #=> ["foo"]
M1.moo
M1.instance_methods false #=> []
module
M2
def foo
end
def self.moo
undef_method :foo
end
end
M2.instance_methods false #=> ["foo"]
M2.moo
M2.instance_methods false #=> []
//}...