Difference between revisions of "Defer"

From wikieduonline
Jump to navigation Jump to search
Line 4: Line 4:
  
 
== Example ==
 
== Example ==
<pre>
 
package main
 
  
import "fmt"
+
package main
 
+
import "fmt"
func main() {
+
defer fmt.Println("world")
+
[[func]] main() {
 
+
defer fmt.Println("world")
fmt.Println("hello")
+
}
+
fmt.Println("hello")
</pre>
+
}
  
 
== See also ==
 
== See also ==

Revision as of 15:57, 21 August 2022


Example

package main
import "fmt"

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

	fmt.Println("hello")
}

See also

Advertising: