We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
{ }
今の ESM Ruby Style Guideだと { と | の間にスペースをいれない。
{
|
[].map {|i| i }
ESM Ruby Style Guide だと
無名関数様をハッシュみたいな見た目にするのは失礼に当たる
@hidenba いわく
do ... end の場合は ブロックパラメータの前後に空白入るからブレースの時も空白入れるようにしてる
@koic いわく
俺もそうしていたけれど、 { と |o| の間の空白は横に間延びした感 (あるいはブロック引数の浮いてしまっている感) があって冗長なので、今は do ... end と別に考えるようにしている。 つまりこの場合は例示のように {|o| として空白は入れない。
The text was updated successfully, but these errors were encountered:
転載ありがとう。補足です。
ブロックが手続きを表現しているなら do ... end を使う。ブロックが式を表現しているなら { ... } を使う。
なので do ... end と { ... } は別に考えています。
do ... end
{ ... }
Sorry, something went wrong.
[IMO]
{|のあいだにはスペース入れない派だったけど、チームの規約のときにそこ頑張るところかな…と思いはじめたので、
{|
nums = (0..10).map { |i| i * 2 } File.open('/tmp/nums.txt', 'w') do |f| f.write(nums) end
でいいんじゃないかなと思うようになった(人間、慣れるものですね)。 手続きが1行のときに:
File.open('/tmp/nums.txt', 'w') do|f| f.write(nums) end File.open('/tmp/nums.txt', 'w') do|f| f.write(nums)end
とは書かないし、--auto-correct効くからこれでいっかー 😩 という。
--auto-correct
戻り値を使うのか、手続きの表現なのかで使い分けることと、 記述を書き分ける、っていうのは別の話だと思うので、書き方としては揃えちゃっていいんじゃないかしら。効用としては:
あくまで標準としての説明のし易さ、ってことなのでチームで合意の上で別の設定にすることは誰にも止められない。
No branches or pull requests
今の ESM Ruby Style Guideだと
{
と|
の間にスペースをいれない。ESM Ruby Style Guide だと
@hidenba いわく
@koic いわく
The text was updated successfully, but these errors were encountered: