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

Update File.extname samplecode for Ruby 2.7 update #2274

Merged
merged 1 commit into from
May 26, 2020

Conversation

pocke
Copy link
Member

@pocke pocke commented May 26, 2020

#2071

Ruby 2.7でFile.extnameの挙動が変わったので、サンプルコードを更新します。

RDoc: https://docs.ruby-lang.org/en/2.7.0/File.html#method-c-extname

Ruby 2.7 からは.で終わる文字列をFile.extnameに渡した時の挙動が変わりました。
また、これはWindowsとそれ以外のOSで挙動が違います。

そのため、Windowsの場合とそうでない場合をサンプルコードに併記しています。

また、ついでに#@samplecode化をしています

@znz znz merged commit 8c68f5e into rurema:master May 26, 2020
@znz
Copy link
Member

znz commented May 26, 2020

良さそうだったのでマージしてしまいましたが、 2.6 以前の File.extname("foo.") の例もあると良いかもしれません。

@pocke pocke deleted the File.extname branch May 26, 2020 14:31
@pocke
Copy link
Member Author

pocke commented May 26, 2020

Ruby 2.6だと空文字列が返るんですね。
あっても良いかなと思う一方、2.7で変わる挙動なので、書くならそれを注釈として書く必要があるかなと思いました。でないと2.6の例を見て、2.7以降で壊れるコードを書く人が出てきてしまうかもしれません

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