| 
									
										
										
										
											2019-06-30 17:04:27 +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-06-30 17:04:27 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | package main | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import "fmt" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func main() { | 
					
						
							|  |  |  | 	a, b := 3.14, 6.28 | 
					
						
							|  |  |  | 	swap(&a, &b) | 
					
						
							|  |  |  | 	fmt.Printf("a : %g — b : %g\n", a, b) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	pa, pb := &a, &b | 
					
						
							|  |  |  | 	pa, pb = swapAddr(pa, pb) | 
					
						
							|  |  |  | 	fmt.Printf("pa: %p — pb: %p\n", pa, pb) | 
					
						
							|  |  |  | 	fmt.Printf("pa: %g — pb: %g\n", *pa, *pb) | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func swap(a, b *float64) { | 
					
						
							|  |  |  | 	*a, *b = *b, *a | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func swapAddr(a, b *float64) (*float64, *float64) { | 
					
						
							|  |  |  | 	return b, a | 
					
						
							|  |  |  | } |