Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* remoção \n desnecessário no Println; variável numero foi modificada para receber valor no escopo acima dos switchs; criação de switch para demonstrar o uso de condicionais * alteracao no readme e adicao de sintaxe ao playground * formas do array * remocao de palavra repetida
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Arrays | ||
```go | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
//declarando um array | ||
var a [3]int | ||
|
||
a[0] = 1 | ||
a[1] = 2 | ||
a[2] = 3 | ||
|
||
fmt.Println(a) | ||
|
||
//declarando um array usando forma de declaração curta | ||
a2 := [3]int{4, 5, 6} | ||
fmt.Println(a2) | ||
|
||
//declarando array com valores preenchidos | ||
var a3 = [3]int{7, 8, 9} | ||
fmt.Println(a3) | ||
|
||
//declarando array array especificando as posições dos elementos | ||
var a4 = [3]int{2: 12, 1: 11, 0: 10} | ||
fmt.Println(a4) | ||
|
||
/*declarando array com elipse, onde quem determina o tamanho do array | ||
é a quantidade de elementos informados | ||
*/ | ||
a5 := [...]int{13, 14, 15} | ||
fmt.Println(a5) | ||
|
||
} | ||
``` | ||
[Playground](https://play.golang.org/p/YmmfIIFO_By) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
//declarando um array | ||
var a [3]int | ||
|
||
a[0] = 1 | ||
a[1] = 2 | ||
a[2] = 3 | ||
|
||
fmt.Println(a) | ||
|
||
//declarando um array usando forma de declaração curta | ||
a2 := [3]int{4, 5, 6} | ||
fmt.Println(a2) | ||
|
||
//declarando array com valores preenchidos | ||
var a3 = [3]int{7, 8, 9} | ||
fmt.Println(a3) | ||
|
||
//declarando array especificando as posições dos elementos | ||
var a4 = [3]int{2: 12, 1: 11, 0: 10} | ||
fmt.Println(a4) | ||
|
||
/*declarando array com elipse, onde quem determina o tamanho do array | ||
é a quantidade de elementos informados | ||
*/ | ||
a5 := [...]int{13, 14, 15} | ||
fmt.Println(a5) | ||
|
||
} |