Skip to content

OptionParser::Arguable#getopts の引数を追加(symbolize_names)#2981

Merged
znz merged 3 commits intorurema:masterfrom
hashimoto-kei:hashimoto-kei-patch-1
Mar 9, 2026
Merged

OptionParser::Arguable#getopts の引数を追加(symbolize_names)#2981
znz merged 3 commits intorurema:masterfrom
hashimoto-kei:hashimoto-kei-patch-1

Conversation

@hashimoto-kei
Copy link
Contributor

OptionParser::Arguable#getopts の引数として symbolize_names を追加しました。

FYI, 英語版のドキュメントには当該オプションに関する記述があります。

class OptionParser - Documentation for Ruby 3.4

Option symbolize_names (boolean) specifies whether returned Hash keys should be Symbols; defaults to false (use Strings).

Copy link
Member

@znz znz left a comment

Choose a reason for hiding this comment

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

Ruby 3.3 からのようなので、バージョン分岐を入れてください。

docker run --platform linux/amd64 --rm -it ghcr.io/ruby/all-ruby env LANG=C.UTF-8 ALL_RUBY_SINCE=ruby-3.2 ./all-ruby -r optparse -e 'OptionParser.new.getopts("x", symbolize_names: true) rescue p($!)'   
ruby-3.2.0          #<NoMethodError: undefined method `split' for {:symbolize_names=>true}:Hash>
...
ruby-3.2.9          #<NoMethodError: undefined method `split' for {:symbolize_names=>true}:Hash>
ruby-3.3.0-preview1 
...
ruby-3.5.0-preview1 

@hashimoto-kei
Copy link
Contributor Author

@znz

Ruby 3.3 からのようなので、バージョン分岐を入れてください。

ご対応が遅れてしまいすみません、こちら以下のようにバージョン分岐を追加してみました。
5891fab

Copy link
Member

@znz znz left a comment

Choose a reason for hiding this comment

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

ありがとうございます。

@znz znz merged commit ac4dd33 into rurema:master Mar 9, 2026
10 checks passed
@hashimoto-kei hashimoto-kei deleted the hashimoto-kei-patch-1 branch March 10, 2026 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants