golang functions and conditional statements

. 1  / * 
2  if: the if statement immediately after a Boolean expression of one or more statements
 . 3  
. 4  IS else: if statement may be used after optional else statements, expressions else statement in the boolean expression is false when executed
 . 5  
. 6  switch: switch statement is used to perform different actions based on different conditions
 . 7  
. 8  select: select switch statement statement is similar, but randomly select a runnable execution case. If there is no case to run, it will block until the case has run
 9  * /
/ * 

FUNC function name (optional: Parameter Type parameter) Optional: Return Value { 
   function body 
} 

function return multiple values: 
Package main 
Import "FMT" 

FUNC main () { 
   A, B: = the swap ( "the Google "," Runoob ") // Runoob the Google 
   fmt.Println (A, B) 
} 

FUNC the swap (X, Y String) (String, String) { 
   return Y, X 
} 
* /

 

Guess you like

Origin www.cnblogs.com/weihexinCode/p/12317023.html