Skip to content

Add example on closure and references #2035

@cuihtlauac

Description

@cuihtlauac

Page: Mutability and Imperative Control Flow
Source: 0it_05_imperative.md

Insert this example (or something similar) in the imperative tutorial.

let counter () =
  let n = ref 0 in
  fun () -> incr n; !n;;

This includes showing how it's used, and how it works.

Credit: https://youtu.be/T_w3OlZ5ASc?t=24m25s

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions