パーソナルツール

while文

作者: 小見 拓 最終変更 2012年01月08日 12時10分

while文

  • while文のサンプル。
:let max = 50
:let index = 0
:while index < 50
    :echo index
    :let index = index + 1
:endwhile
"# => 0
"# => 1
"# => 2
"# => 3
"# => ...
  • while文では「:continue」「:break」を使用できる。
:let max = 50
:let index = 0
:while index < max
    :let index = index + 1
    :if index % 2 == 0
        :continue
    :endif
    :echo index
    :if index > 6
        :break
    :endif
:endwhile
"# => 1
"# => 3
"# => 5
"# => 7
ドキュメントアクション
コメント
blog comments powered by Disqus