defer function and 10 even number calculated
This commit is contained in:
parent
dda9efb15b
commit
151afe99bb
1 changed files with 7 additions and 1 deletions
|
@ -3,6 +3,9 @@ package defer_statement
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func Demo2(number int) string{
|
func Demo2(number int) string{
|
||||||
|
|
||||||
|
defer DeferFunc()
|
||||||
|
|
||||||
if number % 2 == 0{
|
if number % 2 == 0{
|
||||||
return "Even number"
|
return "Even number"
|
||||||
}
|
}
|
||||||
|
@ -15,7 +18,10 @@ func Demo2(number int) string{
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test() {
|
func Test() {
|
||||||
result := Demo2(9)
|
result := Demo2(10)
|
||||||
fmt.Println("Result", result)
|
fmt.Println("Result", result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DeferFunc() {
|
||||||
|
fmt.Println("End !")
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue