0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

内包表記を使ったリファクタリングの例

0
Posted at

やったこと

こういう書き方を

こういうふうに書き変えた。

この書き方の是非

基本的に、2重ループを内包表記で書くのは慎重になるべきだ。大抵は読みにくくなる。今回は、例外的な事例だろう。この辺、どこまで許されて、どこからダメかは人にもよる。

productを使わないようにする例

iterable.productを使うという手もあるが、使わなくともよいのなら使わない。この場合はa | bと書けるから、内包表記で書いた方が読みやすくもあるだろう。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?