Hard work by INTERNET

ベンチャーで働くひとりぼっちWEB開発者が頑張るブログ

railsのアンダースコアに変換するメソッドの戻り値がおかしいんけど

github.com String inflection method underscore giving wrong output #37163

質問

アンダースコアライズする文字列変換文字列のアウトプットがおかしいんだが?

Open up rails console and type - "ActLikeStar".underscore gives you 'act_like_star' which is correct.

rals consoleでこれを入力すると、"ActLikeStar".underscore 'act_like_star' になる。これは正しい。

Now Type - "AB".undescore . which gives you 'ab' which seems to be incorrect.

次は "AB".undescore .を入れると 'ab' になる。おかしい。 a_b のような出力を与えるべきだ。 It should give output like this 'a_b'

回答

これは期待通りの振る舞いです。頭字語の見た目がナイスになります。 あなたは他の変換例をもっと見ることができるよ。

github.com

回答2

先の人が回答したように想定した振る舞いです。 全角だけで表現している場合は、ほとんどのケースではアンダースコアを含めないことを期待している。

おわり