別のキーワード
クラス
- Array (10)
- BasicObject (72)
- Enumerator (48)
-
Enumerator
:: Lazy (48) - Method (92)
- Module (144)
- NameError (24)
- NoMethodError (12)
- Object (216)
- Proc (12)
- Regexp (24)
- Thread (12)
- TracePoint (7)
- UnboundMethod (24)
キーワード
- === (8)
- [] (24)
- args (12)
-
bind
_ call (12) - call (24)
-
class
_ exec (12) -
define
_ singleton _ method (24) - dig (10)
- each (48)
-
enum
_ for (48) - inspect (12)
-
instance
_ eval (24) -
instance
_ method (12) -
instance
_ methods (12) - match (24)
- method (12)
-
method
_ missing (12) - methods (12)
-
module
_ exec (12) - name (12)
-
private
_ instance _ methods (12) -
private
_ methods (12) -
protected
_ instance _ methods (12) -
protected
_ methods (12) - public (48)
-
public
_ instance _ method (12) -
public
_ instance _ methods (12) -
public
_ method (12) -
public
_ methods (12) - receiver (12)
-
respond
_ to? (12) -
respond
_ to _ missing? (12) - send (24)
-
singleton
_ method (12) -
singleton
_ method _ added (12) -
singleton
_ method _ removed (12) -
singleton
_ method _ undefined (12) -
singleton
_ methods (12) -
to
_ enum (48) -
to
_ s (24)
検索結果
先頭5件
-
Enumerator
# each(*args) { . . . } -> object (129.0) -
生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。
...rld"]
obj = Object.new
def obj.each_arg(a, b=:b, *rest)
yield a
yield b
yield rest
:method_returned
end
enum = obj.to_enum :each_arg, :a, :x
enum.each.to_a # => [:a, :x, []]
enum.each.equal?(enum) # => true
enum.each { |elm| elm } # => :method_returned......enum.each(:y, :z).to_a # => [:a, :x, [:y, :z]]
enum.each(:y, :z).equal?(enum) # => false
enum.each(:y, :z) { |elm| elm } # => :method_returned
//}... -
TracePoint
# parameters -> [object] (126.0) -
現在のフックが属するメソッドまたはブロックのパラメータ定義を返します。 フォーマットは Method#parameters と同じです。
...現在のフックが属するメソッドまたはブロックのパラメータ定義を返します。
フォーマットは Method#parameters と同じです。
@raise RuntimeError :call、:return、:b_call、:b_return、:c_call、:c_return
イベントのためのイベン......トフックの外側で実行した場合に発生します。
//emlist[例][ruby]{
def foo(a, b = 2)
end
TracePoint.new(:call) do |tp|
p tp.parameters # => a], [:opt, :b
end.enable do
foo(1)
end
//}
@see Method#parameters, UnboundMethod#parameters, Proc#parameters... -
Enumerator
:: Lazy # enum _ for(method = :each , *args) -> Enumerator :: Lazy (123.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
...
Object#to_enum と同じですが、Enumerator::Lazy を返します。
to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が... -
Enumerator
:: Lazy # enum _ for(method = :each , *args) {|*args| block} -> Enumerator :: Lazy (123.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
...
Object#to_enum と同じですが、Enumerator::Lazy を返します。
to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が... -
Enumerator
:: Lazy # to _ enum(method = :each , *args) -> Enumerator :: Lazy (123.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
...
Object#to_enum と同じですが、Enumerator::Lazy を返します。
to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が... -
Enumerator
:: Lazy # to _ enum(method = :each , *args) {|*args| block} -> Enumerator :: Lazy (123.0) -
Object#to_enum と同じですが、Enumerator::Lazy を返します。
...
Object#to_enum と同じですが、Enumerator::Lazy を返します。
to_enum は「ブロック付きで呼ぶとループを実行し、ブロックを省略した場合は
Enumerator を返す」ようなメソッドを定義するときによく使われます。
このときに lazy 性が... -
Module
# class _ exec(*args) {|*vars| . . . } -> object (111.0) -
与えられたブロックを指定された args を引数としてモジュールのコンテキストで評価します。
...す引数を指定します。
//emlist[例][ruby]{
class Thing
end
c = 1
Thing.class_exec{
def hello()
"Hello there!"
end
define_method(:foo) do # ローカル変数がブロックの外側を参照している
c
end
}
t = Thing.new
p t.hello() #=> "Hello there!"... -
Module
# module _ exec(*args) {|*vars| . . . } -> object (111.0) -
与えられたブロックを指定された args を引数としてモジュールのコンテキストで評価します。
...す引数を指定します。
//emlist[例][ruby]{
class Thing
end
c = 1
Thing.class_exec{
def hello()
"Hello there!"
end
define_method(:foo) do # ローカル変数がブロックの外側を参照している
c
end
}
t = Thing.new
p t.hello() #=> "Hello there!"... -
Array
# dig(idx , . . . ) -> object | nil (110.0) -
self 以下のネストしたオブジェクトを dig メソッドで再帰的に参照して返し ます。途中のオブジェクトが nil であった場合は nil を返します。
...ます。
//emlist[例][ruby]{
a = [[1, [2, 3]]]
a.dig(0, 1, 1) # => 3
a.dig(1, 2, 3) # => nil
a.dig(0, 0, 0) # => TypeError: Fixnum does not have #dig method
[42, {foo: :bar}].dig(1, :foo) # => :bar
//}
@see Hash#dig, Struct#dig, OpenStruct#dig......ます。
//emlist[例][ruby]{
a = [[1, [2, 3]]]
a.dig(0, 1, 1) # => 3
a.dig(1, 2, 3) # => nil
a.dig(0, 0, 0) # => TypeError: Integer does not have #dig method
[42, {foo: :bar}].dig(1, :foo) # => :bar
//}
@see Hash#dig, Struct#dig, OpenStruct#dig...