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
Show file tree
Hide file tree
Changes from all commits
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
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]]
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