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 document for (Proc|Method)#(<<|>>) since Ruby 2.6 #2282

Merged
merged 1 commit into from
Jun 9, 2020

Conversation

pocke
Copy link
Member

@pocke pocke commented Jun 8, 2020

#1977

Ruby 2.6 から追加された、 Proc#>>, Proc#<<, Method#>>, Method#<< のドキュメントを追加します。

説明文やサンプルコードは、RDocのものをベースにしています。
https://docs.ruby-lang.org/en/2.7.0/Proc.html#method-i-3E-3E

@pocke pocke added the Ruby2.6.0 label Jun 8, 2020
Hello, Ruby!
TEXT

pipeline = proc { |fname| File.read(fname) } >> WordScanner >> method(:p)
Copy link
Member Author

Choose a reason for hiding this comment

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

多少見た目がかっこ悪いですが、Proc#>>が呼ばれるように、わざと File.method(:read)ではなく、procを作っています。

pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
#@end

@see [[m:Proc#<<]], [[m:Proc#>>]]
Copy link
Member Author

Choose a reason for hiding this comment

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

本文中に Method#>>へのリンクはあるので、see alsoには Procへのリンクだけを足しています。これは他のメソッドも同様です。

see also にも足したほうが良ければ教えてください

Comment on lines +157 to +158
# (3 + 3) * (3 + 3)
p (method(:f) << method(:g)).call(3) # => 36
Copy link
Member Author

Choose a reason for hiding this comment

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

このへん、RDocだと2を渡しているのですが、2という数字はx * xx + xで暗に出てきてややこしいので、代わりに3を渡してみました。

@znz znz merged commit ab6d264 into rurema:master Jun 9, 2020
@pocke pocke deleted the Proc#>><< branch June 9, 2020 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants