Skip to content

Commit 26f8a95

Browse files
authored
Merge pull request #2286 from znz/bind_call
Add UnboundMethod#bind_call since 2.7.0
2 parents 8558686 + 46441ed commit 26f8a95

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

refm/api/src/_builtin/Method

+3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ self[] の形の呼び出しは通常のメソッド呼び出しに見た目を
118118

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

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

refm/api/src/_builtin/UnboundMethod

+15
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,21 @@ NOTE: Ruby 1.8.xでモジュールのインスタンスメソッドをbindする
9999
end
100100
p m.bind(Bar.new) # => #<Method: Bar(Foo)#foo>
101101

102+
#@since 2.7.0
103+
@see [[m:UnboundMethod#bind_call]]
104+
--- bind_call(recv, *args) -> object
105+
--- bind_call(recv, *args) { ... } -> object
106+
107+
self を recv に bind して args を引数として呼び出します。
108+
109+
self.bind(recv).call(*args) と同じ意味です。
110+
111+
#@samplecode
112+
puts Kernel.instance_method(:inspect).bind_call(BasicObject.new) # => #<BasicObject:0x000055c65e8ea7b8>
113+
#@end
114+
115+
@see [[m:UnboundMethod#bind]], [[m:Method#call]]
116+
#@end
102117
--- arity -> Integer
103118

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

0 commit comments

Comments
 (0)