| 
									
										
										
										
											2018-12-18 15:20:37 +03:00
										 |  |  | // For more tutorials: https://blog.learngoprogramming.com | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // Copyright © 2018 Inanc Gumus | 
					
						
							|  |  |  | // Learn Go Programming Course | 
					
						
							|  |  |  | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | package main | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import "fmt" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // --------------------------------------------------------- | 
					
						
							|  |  |  | // EXERCISE: Declare the arrays as slices | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | //   1. First run the following program as it is | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | //   2. Then change the array declarations to slice declarations | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | //   3. Observe whether anything changes or not (on the surface :)). | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | // EXPECTED OUTPUT | 
					
						
							|  |  |  | //  names    : []string ["Einstein" "Tesla" "Shepard"] | 
					
						
							|  |  |  | //  distances: []int [50 40 75 30 125] | 
					
						
							|  |  |  | //  data     : []uint8 [72 69 76 76 79] | 
					
						
							| 
									
										
										
										
											2019-01-25 14:04:03 +03:00
										 |  |  | //  ratios   : []float64 [3.14] | 
					
						
							| 
									
										
										
										
											2018-12-18 15:20:37 +03:00
										 |  |  | //  alives   : []bool [true false true false] | 
					
						
							|  |  |  | //  zero     : []uint8 [] | 
					
						
							|  |  |  | // --------------------------------------------------------- | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func main() { | 
					
						
							|  |  |  | 	names := [3]string{"Einstein", "Tesla", "Shepard"} | 
					
						
							|  |  |  | 	distances := [...]int{50, 40, 75, 30, 125} | 
					
						
							|  |  |  | 	data := [5]byte{'H', 'E', 'L', 'L', 'O'} | 
					
						
							|  |  |  | 	ratios := [1]float64{3.14145} | 
					
						
							|  |  |  | 	alives := [...]bool{true, false, true, false} | 
					
						
							|  |  |  | 	zero := [0]byte{} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	fmt.Printf("names    : %[1]T %[1]q\n", names) | 
					
						
							|  |  |  | 	fmt.Printf("distances: %[1]T %[1]d\n", distances) | 
					
						
							|  |  |  | 	fmt.Printf("data     : %[1]T %[1]d\n", data) | 
					
						
							| 
									
										
										
										
											2019-01-25 14:04:03 +03:00
										 |  |  | 	fmt.Printf("ratios   : %[1]T %.2[1]f\n", ratios) | 
					
						
							| 
									
										
										
										
											2018-12-18 15:20:37 +03:00
										 |  |  | 	fmt.Printf("alives   : %[1]T %[1]t\n", alives) | 
					
						
							|  |  |  | 	fmt.Printf("zero     : %[1]T %[1]d\n", zero) | 
					
						
							|  |  |  | } |