るりまサーチ

最速Rubyリファレンスマニュアル検索!
6件ヒット [1-6件を表示] (0.034秒)
トップページ > クエリ:Method[x] > クエリ:import_methods[x]

別のキーワード

  1. rake import
  2. fiddle/import malloc
  3. kernel import
  4. fiddle/import to_i
  5. fiddle/import sizeof

ライブラリ

クラス

検索結果

Refinement#import_methods(*modules) -> self (24225.0)

モジュールからメソッドをインポートします。

...モジュールからメソッドをインポートします。

Module#includeと違って、import_methods はメソッドをコピーして
refinement に追加して、refinementでインポートしたメソッドを有効化します。

メソッドをコピーするため、Rubyコードで...
...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#drop
end
end
//}...

NEWS for Ruby 3.1.0 (42.0)

NEWS for Ruby 3.1.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...* MatchData#match_length が追加されました。 18172

* Method / UnboundMethod
* 新規メソッド
* Method#public?, Method#private?, Method#protected?, UnboundMethod#public?, UnboundMethod#private?, UnboundMethod#protected? が追加されました。 11689

* Module
*...
...inement
* Module#refineで作成されたモジュールを表す新しいクラス。includeとprependは非推奨になり、代わりにimport_methodsが追加されました。

== 標準添付ライブラリの更新(機能追加とバグ修正を除く)

* 以下のdefault gemsが更新...
...test.rb:2:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError)

title = json[:article][:title]
^^^^^^^^^^
//}

json[:article] が返す時、

//emlist{
$ ruby test.rb
test.rb:2:in `<main>': undefined method `[]' for nil:NilClass (NoMethodError)

title = json[:article][:t...