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
2a1683a0
Commit
2a1683a0
authored
Apr 20, 2009
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spec change for redeclaration
R=iant,gri DELTA=14 (14 added, 0 deleted, 0 changed) OCL=27615 CL=27618
parent
549a6004
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
go_spec.html
doc/go_spec.html
+14
-0
No files found.
doc/go_spec.html
View file @
2a1683a0
...
@@ -1674,6 +1674,20 @@ variables will be assigned the corresponding values.
...
@@ -1674,6 +1674,20 @@ variables will be assigned the corresponding values.
r, w := os.Pipe(fd); // os.Pipe() returns two values
r, w := os.Pipe(fd); // os.Pipe() returns two values
</pre>
</pre>
<p>
A short variable declaration may redeclare variables provided they
were originally declared in the same block with the same type, and at
least one of the variables is new. As a consequence, redeclaration
can only appear in a multi-variable short declaration.
Redeclaration does not introduce a new
variable; it just assigns a new value to the original.
</p>
<pre>
field1, offset := nextField(str, 0);
field2, offset := nextField(str, offset); // redeclares offset
</pre>
<p>
<p>
Short variable declarations may appear only inside functions.
Short variable declarations may appear only inside functions.
In some contexts such as the initializers for
<code>
if
</code>
,
In some contexts such as the initializers for
<code>
if
</code>
,
...
...
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