---
title: "Discussion on \"Go Cheatsheet - Function Closure\" | Hashnode"
description: "Discussion on \"Go Cheatsheet - Function Closure\". Functions\nClosure to hide variable\n// i will be saved in this function's context\nfunc intSeq() func() int {\n    i := 0\n    return func() int {\n        i++\n        return i\n    }\n}\n\nnextInt := intSeq()\nnextInt() // 1\nnextInt() // 2"
url: "https://hashnode.com/posts/go-cheatsheet-function-closure/6081acf1ff5fc65284a76875"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Go Cheatsheet - Function Closure](https://hn.0xbf.me/go-cheatsheet-function-closure?utm_source=hashnode&utm_medium=feed)

Functions Closure to hide variable // i will be saved in this function's context func intSeq() func() int { i := 0 return func() int { i++ return i } } nextInt := intSeq() nextInt() // 1 nextInt() // 2

Apr 22, 2021 · 1 min read · hn.0xbf.me  
Read the article

-   [#go](https://hashnode.com/tag/go)

## Written by

[0xBF](https://hashnode.com/@0xbf)

@0xbf

  
[View profile](https://hashnode.com/@0xbf)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
