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?

More than 1 year has passed since last update.

PowerShellでのfor文サンプル

Last updated at Posted at 2023-10-29

コードのサンプル

# 他の言語のfor(i=1;i<10;i++) に相当
for ($i=1; $i -lt 10; $i++){
	write-host $i
}

# 他の言語for(i=1;i<=10;i++) に相当
for ($i=1; $i -le 10; $i++){
	write-host $i
}

実行結果

1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
10

なんでこんなものを。

ここに書くほどのことではないのかもしれないのですが、PowerShellは比較演算子が独特すぎる ということに最初に気づかず、for文を書くのにも苦しみました。
自分と同じ初学者の方のためになればと思い、自分への備忘も兼ねての投稿となります。

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?