Skip to content

Commit

Permalink
Merge pull request #2286 from znz/bind_call
Browse files Browse the repository at this point in the history
Add UnboundMethod#bind_call since 2.7.0
  • Loading branch information
znz authored Jun 30, 2020
2 parents 8558686 + 46441ed commit 26f8a95
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions refm/api/src/_builtin/Method
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ self[] の形の呼び出しは通常のメソッド呼び出しに見た目を

@param args self に渡される引数。

#@since 2.7.0
@see [[m:UnboundMethod#bind_call]]
#@end
@see [[d:spec/safelevel]]
#@# セーフレベルに関するその他の詳細

Expand Down
15 changes: 15 additions & 0 deletions refm/api/src/_builtin/UnboundMethod
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,21 @@ NOTE: Ruby 1.8.xでモジュールのインスタンスメソッドをbindする
end
p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>

#@since 2.7.0
@see [[m:UnboundMethod#bind_call]]
--- bind_call(recv, *args) -> object
--- bind_call(recv, *args) { ... } -> object

self を recv に bind して args を引数として呼び出します。

self.bind(recv).call(*args) と同じ意味です。

#@samplecode
puts Kernel.instance_method(:inspect).bind_call(BasicObject.new) # => #<BasicObject:0x000055c65e8ea7b8>
#@end

@see [[m:UnboundMethod#bind]], [[m:Method#call]]
#@end
--- arity -> Integer

メソッドが受け付ける引数の数を返します。
Expand Down

0 comments on commit 26f8a95

Please sign in to comment.