PerlerのRuby日記

Rubyとか

2013-07-29から1日間の記事一覧

短いけどわかりにくいコードを可読性考えて書きなおしてみた

なんかこういう感じのコードがあったので、 def readable? !Hoge.count(self) == 0 && self.title != "" end こういう感じに書き換えた。 def readable? return false if Hoge.count(self) == 0 return false if self.title == "" true end 3行に増えたけど…