種類
- クラス (3)
- インスタンスメソッド (3)
クラス
- Refinement (3)
検索結果
-
Refinement
# import _ methods(*modules) -> self (26121.0) -
モジュールからメソッドをインポートします。
...モジュールからメソッドをインポートします。
Module#includeと違って、import_methods はメソッドをコピーして
refinement に追加して、refinementでインポートしたメソッドを有効化します。
メソッドをコピーするため、Rubyコードで......Utils
def indent(level)
' ' * level + self
end
end
module M
refine String do
import_methods StrUtils
end
end
using M
p "foo".indent(3) # => " foo"
module M
refine String do
import_methods Enumerable
# Can't import method which is not defined with Ruby code: Enumerable#... -
Refinement (8008.0)
-
refine のブロックの中の self のクラスです。
...refine のブロックの中の self のクラスです。
Refinement#import_methodsで他のモジュールからメソッドを
インポートできます。...