Difference between revisions of "Defer"

From wikieduonline
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
* https://go.dev/tour/flowcontrol/12
 
* https://go.dev/tour/flowcontrol/12
  
<pre>
 
package main
 
  
import "fmt"
+
== Example ==
  
func main() {
+
[[package main]]
defer fmt.Println("world")
+
[[import]] "fmt"
 
+
fmt.Println("hello")
+
[[func]] main() {
}
+
defer fmt.Println("world")
</pre>
+
 +
fmt.Println("hello")
 +
}
  
 
== See also ==
 
== See also ==
 
* {{Go}}
 
* {{Go}}
* {{flow}}
+
* {{flow control}}
  
 
[[Category:Go]]
 
[[Category:Go]]

Latest revision as of 15:58, 21 August 2022


Example[edit]

package main
import "fmt"

func main() {
	defer fmt.Println("world")

	fmt.Println("hello")
}

See also[edit]

Advertising: