File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ func NewRegister() mapping.Register {
1515func (r * register ) Regist (m mapping.ExampleMapping ) {
1616 m ["loops_basic_for_loop" ] = BasicForLoop
1717 m ["loops_basic_foreach" ] = BasicForeach
18+ m ["loops_while_loop" ] = WhileLoop
1819 m ["loops_channel_loop" ] = ChannelLoop
1920 m ["loops_slice_loop" ] = SliceLoop
2021 m ["loops_map_loop" ] = MapLoop
Original file line number Diff line number Diff line change 1+ package loops
2+
3+ import (
4+ "github.com/devlights/gomy/output"
5+ )
6+
7+ // WhileLoop は、GoでのWhileループについてのサンプルです.
8+ func WhileLoop () error {
9+ // Go には、ループはすべて for で記載することになっている。
10+ // 他の言語にある while () {} は提供されていない。
11+ count := 5
12+ for count > 0 {
13+ output .Stdoutl ("[count]" , count )
14+ count -= 1
15+ }
16+
17+ return nil
18+ }
You can’t perform that action at this time.
0 commit comments