Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
091cba8d
Commit
091cba8d
authored
Mar 19, 2009
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor adjustments to switches text
R=r DELTA=16 (5 added, 1 deleted, 10 changed) OCL=26530 CL=26543
parent
37ab838d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
11 deletions
+15
-11
go_spec.html
doc/go_spec.html
+15
-11
No files found.
doc/go_spec.html
View file @
091cba8d
...
...
@@ -3133,6 +3133,11 @@ if x := f(); x < y {
An expression or type specifier is compared to the "cases"
inside the "switch" to determine which branch
to execute.
<pre
class=
"grammar"
>
SwitchStat = ExprSwitchStat | TypeSwitchStat .
</pre>
There are two forms: expression switches and type switches.
In an expression switch, the cases contain expressions that are compared
against the value of the switch expression.
...
...
@@ -3159,10 +3164,9 @@ the expression <code>true</code>.
</p>
<pre
class=
"grammar"
>
SwitchStat = ExprSwitchStat | TypeSwitchStat .
ExprSwitchStat = "switch" [ [ SimpleStat ] ";" ] [ Expression ] "{" { ExprCaseClause } "}" .
ExprCaseClause = ExprSwitchCase ":" [ StatementList ] .
ExprSwitchCase = "case" ExpressionList | "default" .
ExprSwitchStat = "switch" [ [ SimpleStat ] ";" ] [ Expression ] "{" { ExprCaseClause } "}" .
ExprCaseClause = ExprSwitchCase ":" [ StatementList ] .
ExprSwitchCase = "case" ExpressionList | "default" .
</pre>
<p>
...
...
@@ -3217,10 +3221,10 @@ in the type guard.
</p>
<pre
class=
"grammar"
>
TypeSwitchStat
= "switch" [ [ SimpleStat ] ";" ] TypeSwitchGuard "{" { TypeCaseClause } "}" .
TypeSwitchGuard
= identifier ":=" Expression "." "(" "type" ")" .
TypeCaseClause
= TypeSwitchCase ":" [ StatementList ] .
TypeSwitchCase
= "case" type | "default" .
TypeSwitchStat = "switch" [ [ SimpleStat ] ";" ] TypeSwitchGuard "{" { TypeCaseClause } "}" .
TypeSwitchGuard = identifier ":=" Expression "." "(" "type" ")" .
TypeCaseClause = TypeSwitchCase ":" [ StatementList ] .
TypeSwitchCase = "case" type | "default" .
</pre>
<p>
...
...
@@ -3642,9 +3646,9 @@ the creation of <code>v</code>.
<p>
A "fallthrough" statement transfers control to the first statement of the
next case clause in a
"switch" statement (§Switch statement
s). It may
be used only as the final non-empty statement in a case or default clause in a
"switch" statement.
next case clause in a
expression "switch" statement (§Expression switche
s). It may
be used only as the final non-empty statement in a case or default clause in a
n
expression
"switch" statement.
</p>
<pre
class=
"grammar"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment