るりまサーチ

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

別のキーワード

  1. _builtin end
  2. ripper end_seen?
  3. _builtin exclude_end?
  4. _builtin end_with?
  5. range end

ライブラリ

クラス

オブジェクト

キーワード

検索結果

main.using(module) -> self (18132.0)

引数で指定したモジュールで定義された拡張を有効にします。

...ents_rdoc.html#label-Scope

@param module 有効にするモジュールを指定します。

//emlist[例][ruby]{
module Sloth
refine String do
def downcase
self
end

end

end


"ABC".downcase # => "abc"

using
Sloth

"ABC".downcase # => "ABC"
//}

@see Module#refine, Module#using...

Module.used_modules -> [Module] (53.0)

現在のスコープで using されているすべてのモジュールを配列で返します。 配列内のモジュールの順番は未定義です。

...現在のスコープで using されているすべてのモジュールを配列で返します。
配列内のモジュールの順番は未定義です。

//emlist[例][ruby]{
module A
refine Object do
end

end


module B
refine Object do
end

end


using
A
using
B
p Module.used_modules
#=...

Proc.new -> Proc (25.0)

ブロックをコンテキストとともにオブジェクト化して返します。

...ブロックを指定しない場合、Ruby 2.7 では
$VERBOSE = true のときには警告メッセージ
「warning: Capturing the given block using Proc.new is deprecated; use `&block` instead」
が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
...
...ったときに発生します。

//emlist[例][ruby]{
def foo
pr = Proc.new
pr.call(1)
end

foo {|arg| p arg }
# => 1
//}

これは以下と同じです。

//emlist[例][ruby]{
def foo
yield(1)
end

foo {|arg| p arg }
# => 1
//}

呼び出し元のメソッドがブロックを伴わなけ...

Proc.new { ... } -> Proc (25.0)

ブロックをコンテキストとともにオブジェクト化して返します。

...ブロックを指定しない場合、Ruby 2.7 では
$VERBOSE = true のときには警告メッセージ
「warning: Capturing the given block using Proc.new is deprecated; use `&block` instead」
が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
...
...ったときに発生します。

//emlist[例][ruby]{
def foo
pr = Proc.new
pr.call(1)
end

foo {|arg| p arg }
# => 1
//}

これは以下と同じです。

//emlist[例][ruby]{
def foo
yield(1)
end

foo {|arg| p arg }
# => 1
//}

呼び出し元のメソッドがブロックを伴わなけ...