1
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?

More than 1 year has passed since last update.

【GAS】forEachがいつの間にか非推奨だった件

Posted at

はじめに

弊社では定期実行される処理にGAS(Google Apps Script)を使用しているのですが、放置しているといつの間にか動かなくなっていたりするので定期的にチェックするようにしています。
その際に一部修正が必要で直していたのですが、forEachがいつの間にか非推奨になっていて少し調べたので備忘録的に残しておこうと思います。

forEachが非推奨、、、

タイトルの通りなのですが、どうやら一年くらい前から非推奨になっていたようですね。
とても便利な印象のforEachですが、GASでは嫌悪されているようです、、、
forEachの中ではbreakやcontinueといった処理が使えないのが嫌悪感の一端を担っていそうですね。

forEachの代わりにforを使おう

名残惜しいですが、forEachが非推奨ということでもう使えないので、forを積極的に使うことにします。
forを使用するとなるとその使い分けが悩ましいところですが、for ofは配列からデータを取り出したいときに用いることが多い一方、for in文はオブジェクトからデータを取り出したいときに用いることが多い印象なのでこの使い分けを基本として選択していくのが良さそうです。

さいごに

またKotlinでサーバー側の対応を行うことになりそうです。

1
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
1
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?