Skip to content

Commit

Permalink
mini spec: Short variable declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Dec 8, 2024
1 parent aa3d7c8 commit 1c362cd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions doc/spec-mini.md
Original file line number Diff line number Diff line change
Expand Up @@ -1991,9 +1991,15 @@ var n = nil // illegal

Implementation restriction: A compiler may make it illegal to declare a variable inside a [function body](#function-declarations) if the variable is never used.

### Short variable declarations
In a function body, variables do not need to be explicitly defined.

TODO
```go
d := math.Sin(0.5) // d is float64
i := 42 // i is int
t, ok := x.(T) // t is T, ok is bool
```

See [short variable declarations](#short-variable-declarations).

### Function declarations

Expand Down

0 comments on commit 1c362cd

Please sign in to comment.