Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add UnboundMethod#bind_call since 2.7.0 #2286

Merged
merged 2 commits into from
Jun 30, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

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

#@since 2.7.0
--- 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]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

逆方向のsee also linkもあったほうが便利かなと思います。

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

追加しました。
46441ed

#@end
--- arity -> Integer

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