Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Cap. 12 – Funções – 10. Closure
Play lesson

Aprenda Go 🇧🇷 - Cap. 12 – Funções – 10. Closure

5.0 (2)
47 learners

What you'll learn

This course includes

  • 21.3 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

- Closure é cercar ou capturar um scope para que possamos utilizá-lo em outro contexto. Já vimos: - Package-level scope - Function-level scope - Code-block-in-code-block scope - Exemplo de closure: - func i() func() int { x := 0; return func() int { x++; return x } } - Quando fizermos a := i() teremos um scope, um valor para x. - Quando fizermos b := i() teremos outro scope, e x terá um valor independente do x acima. - Closures nos permitem salvar dados entre function calls e ao mesmo tempo isolar estes dados do resto do código. - Go Playground: https://play.golang.org/p/AdFciYwI2Z

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere