| 
									
										
										
										
											2019-08-25 08:57:53 +03:00
										 |  |  | // Copyright © 2018 Inanc Gumus | 
					
						
							|  |  |  | // Learn Go Programming Course | 
					
						
							|  |  |  | // License: https://creativecommons.org/licenses/by-nc-sa/4.0/ | 
					
						
							|  |  |  | // | 
					
						
							| 
									
										
										
										
											2019-10-30 19:34:44 +03:00
										 |  |  | // For more tutorials  : https://learngoprogramming.com | 
					
						
							|  |  |  | // In-person training  : https://www.linkedin.com/in/inancgumus/ | 
					
						
							|  |  |  | // Follow me on twitter: https://twitter.com/inancgumus | 
					
						
							| 
									
										
										
										
											2019-08-25 08:57:53 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | package main | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import "fmt" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func main() { | 
					
						
							|  |  |  | 	// Let's create a variable using the empty interface type. | 
					
						
							|  |  |  | 	var any interface{} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// The variable can accept any type of value. | 
					
						
							|  |  |  | 	any = []int{1, 2, 3} | 
					
						
							|  |  |  | 	any = map[int]bool{1: true, 2: false} | 
					
						
							|  |  |  | 	any = "hello" | 
					
						
							|  |  |  | 	any = 3 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// You can't multiply the last number. | 
					
						
							|  |  |  | 	// Reason: `any` is an `interface{}`, it's not a number. | 
					
						
							|  |  |  | 	// any = any * 2 | 
					
						
							|  |  |  | 	// any = int(any) * 2 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	any = any.(int) * 2 | 
					
						
							|  |  |  | 	fmt.Println(any) | 
					
						
							|  |  |  | } |