0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

forを無理やりforeachにする

Last updated at Posted at 2018-07-17

他人が書いたコードを読んでいる途中、こんなコードがあった。
同じ処理を5回繰り返す。


foreach(var i in Enumerable.Range(1, 5)) {
    //処理
}

「forを使うやつはアレ」的なコメントがあった。

でも、そのアレな俺が書くと下記。


for(int i = 0; i < 5; i++) {
    //処理
}

なんでforを使うとアレなんでしょ?

0
3
4

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
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?