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

Kernel.#readlinesの返り値等の加筆修正 #2524

Merged
merged 2 commits into from
Apr 25, 2021

Conversation

universato
Copy link
Contributor

@universato universato commented Apr 14, 2021

Kernel.#readlines (Ruby 3.0.0 リファレンスマニュアル)
上記のページに対する修正等です。

  • 返り値[String] | nilからnilを削除
    入力がないときにnilを返すのはRuby 1.8以前の話で、1.9以降は空配列を返すようです。
    サンプルコードの1番最後の返り値も合わせて修正しています。
  • シンタックスハイライトが効くように、#@samplecodeを適用しています。
  • @seeのところがgetsだけだったので、readlineも加えました。

なお、最初のコミットで、ファイル全体の行末の空白を削除しており、
PR全体で見ると主旨の変更点が見えにくいので、その点にご留意ください。


common
#@samplecode b.txt
Copy link
Member

Choose a reason for hiding this comment

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

たまたま ruby のコードとしても解釈できるだけのものに #@samplecode を使っても良いんでしょうか。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

本来の使い方ではないのかもしれませんが、
ハイライトの色も黒一色で見やすく、COPYボタンで最後に改行つきで取れ、ファイル名もわかりやすく、見やすくて現時点ではメリットがあるかなと自分は思いました。

Image from Gyazo

デメリットも考えてみたのですが、将来的にRubyの文法が変わるなどしたら壊れるかもしれませんが、壊れたときは他のコードも壊れたり、そもそも起きる確率が低そうなので、大丈夫だろうと思いました。
ダメという話であれば、変更します。

Copy link
Member

Choose a reason for hiding this comment

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

なるほど、そこまで考えての判断なら良さそうです。

他にもデータファイルなど (CSV とか?) を同じように書きたいことがありそうなので、将来的には bitclust 側で samplecode ではない sampleなんとか があると良いのかもしれません。

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.

None yet

2 participants