From 2ca8a50e92db7efa4a231f541d4a57d2c73f813b Mon Sep 17 00:00:00 2001 From: Lincoln Ruteski Date: Wed, 27 Mar 2024 17:07:11 -0300 Subject: [PATCH] 14.7 funcao closure --- .../14.7-funcao_closure/closure.go | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 14-funcoes_avacadas/14.7-funcao_closure/closure.go diff --git a/14-funcoes_avacadas/14.7-funcao_closure/closure.go b/14-funcoes_avacadas/14.7-funcao_closure/closure.go new file mode 100644 index 0000000..c2240f7 --- /dev/null +++ b/14-funcoes_avacadas/14.7-funcao_closure/closure.go @@ -0,0 +1,21 @@ +package main + +import "fmt" + +func closure() func() { + texto := "Dentro da funcao closure" + + funcao := func() { + fmt.Println(texto) + } + + return funcao +} + +func main() { + texto := "dentro da funcao main" + fmt.Println(texto) + + funcaoNova := closure() + funcaoNova() +}