種類
- インスタンスメソッド (66)
- 文書 (26)
ライブラリ
- ビルトイン (66)
クラス
- Module (66)
キーワード
- <= (11)
- > (11)
- >= (11)
-
NEWS for Ruby 2
. 1 . 0 (11) -
NEWS for Ruby 3
. 0 . 0 (4) -
included
_ modules (11) -
ruby 1
. 6 feature (11)
検索結果
先頭5件
-
Module
# include(*mod) -> self (18185.0) -
モジュール mod をインクルードします。
...てしまうような include を行った場合に発生します。
//emlist[例][ruby]{
module M
end
module M2
include M
end
module M
include M2
end
//}
実行結果:
-:3:in `append_features': cyclic include detected (ArgumentError)
from -:3:in `include'
from -:3......ルードは多重継承の代わりに用いられており、 mix-in とも呼びます。
//emlist[例][ruby]{
class C
include FileTest
include Math
end
p C.ancestors
# => [C, Math, FileTest, Object, Kernel]
//}
モジュールの機能追加は、クラスの継承関係の間にその......#ancestors の結果がメソッド探索の順序です)。
同じモジュールを二回以上 include すると二回目以降は無視されます。
//emlist[例][ruby]{
module M
end
class C1
include M
end
class C2 < C1
include M # この include は無視される
end
p C2.ancestors... -
Module
# ancestors -> [Class , Module] (18113.0) -
クラス、モジュールのスーパークラスとインクルードしているモジュール を優先順位順に配列に格納して返します。
...順位順に配列に格納して返します。
//emlist[例][ruby]{
module Foo
end
class Bar
include Foo
end
class Baz < Bar
p ancestors
p included_modules
p superclass
end
# => [Baz, Bar, Foo, Object, Kernel, BasicObject]
# => [Foo, Kernel]
# => Bar
//}
@see Module#included_modules......先順位順に配列に格納して返します。
//emlist[例][ruby]{
module Foo
end
class Bar
include Foo
end
class Baz < Bar
p ancestors
p included_modules
p superclass
end
# => [Baz, Bar, Foo, Object, Kernel, BasicObject]
# => [Foo, Kernel]
# => Bar
//}
@see Module#included_modules... -
Module
# included _ modules -> [Module] (6112.0) -
self にインクルードされているモジュールの配列を返します。
...self にインクルードされているモジュールの配列を返します。
//emlist[例][ruby]{
module Mixin
end
module Outer
include Mixin
end
Mixin.included_modules #=> []
Outer.included_modules #=> [Mixin]
//}
@see Module#ancestors... -
ruby 1
. 6 feature (60.0) -
ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。
...dev:15684>)),
((<ruby-dev:15757>))
: ((<Module/include>))
モジュールが再帰的に include されないようになりました。
module Foo; end
module Bar; include Foo; end
module Foo; include Bar; end
p Foo.ancestors
=> ruby 1.6.6 (2001-12-26) [i586-linux]......[Foo, Bar, Foo]
=> -:3:in `append_features': cyclic include detected (ArgumentError)
from -:3:in `include'
from -:3
ruby 1.6.6 (2002-01-28) [i586-linux]
: メソッドの戻り値
以下のメソッドの戻り値が正しくなりました。
((<ruby-bug......ind することができませんでした。
((<rubyist:0728>))
module Foo
def foo
:foo
end
end
class Bar
include Foo
end
m = Foo.instance_method :foo
p m.bind(Bar.new).call
=> ruby 1.6.4 (2001-06-04) [i586-linux]
-:12:in `bind': f... -
NEWS for Ruby 2
. 1 . 0 (48.0) -
NEWS for Ruby 2.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...ルであれば false を返します。
* 拡張: Module#refine はもはや実験的な機能でなくなりました
* 拡張: Module#include と Module#prepend はパブリックメソッドになりました
* Mutex
* Mutex#owned? はもはや実験的な機能ではありませ......sing はもはや実験的な機能ではありません。
The method activates refinements in the ancestors of the argument module to
support refinement inheritance by Module#include
=== 組み込みクラスの互換性 (機能追加とバグ修正を除く)
* Hash
* 非互換:......#tainted?,Object#taint,Object#untaint とそれぞれ同じ動作です。
* Module#ancestors
* 特異クラスの祖先はそれ自身を含みます。
The ancestors of a singleton class now include singleton classes,
in particular itself.
* Module#define_method Object#define... -
NEWS for Ruby 3
. 0 . 0 (30.0) -
NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...ntext. 16786
* Module
* Module#include and Module#prepend now affect classes and modules that have already included or prepended the receiver, mirroring the behavior if the arguments were included in the receiver before the other modules and classes included or prepended the receiver. 9573......dule#alias_method now returns the defined alias as a symbol. 17314
//emlist[][ruby]{
class C; end
module M1; end
module M2; end
C.include M1
M1.include M2
p C.ancestors #=> [C, M1, M2, Object, Kernel, BasicObject]
//}
* Mutex
* `Mutex` is now acquired per-`Fiber` instead of per-`Thread`. Thi......iately. This feature is designed by referring to Python's buffer protocol. 13767 14722
* Ractor related C APIs are introduced (experimental) in "include/ruby/ractor.h".
== Implementation improvements
* New method cache mechanism for Ractor. 16614
* Inline method caches pointed from ISeq ca... -
Module
# <=(other) -> bool | nil (18.0) -
比較演算子。self が other の子孫であるか、self と other が 同一クラスである場合、 true を返します。 self が other の先祖である場合、false を返します。
...発生します。
@see Module#<
//emlist[例][ruby]{
module Foo; end
module Bar
include 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... -
Module
# >(other) -> bool | nil (18.0) -
比較演算子。 self が other の先祖である場合、true を返します。 self が other の子孫か同一クラスである場合、false を返します。
...le#<
//emlist[例][ruby]{
module Awesome; end
module Included
include Awesome
end
module Prepended
prepend Awesome
end
Included.ancestors # => [Included, Awesome]
Awesome > Included # => true
Included > Awesome # => false
Prepended.ancestors # => [Awesome, Prepended]
Awesome > Prepended # =>... -
Module
# >=(other) -> bool | nil (18.0) -
比較演算子。self が other の先祖か同一クラスである場合、 true を返します。 self が other の子孫である場合、false を返します。
...発生します。
@see Module#<
//emlist[例][ruby]{
module Foo; end
module Bar
include Foo
end
module Baz
prepend Foo
end
Bar.ancestors # => [Bar, Foo]
Foo >= Bar # => true
Bar >= Foo # => false
Baz.ancestors # => [Foo, Baz]
Foo >= Baz # => true
Baz >= Foo # => false
Foo >= Foo # => true...