Skip to content

Instantly share code, notes, and snippets.

@scrwtp
Created July 3, 2017 22:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scrwtp/6f60cc6ed422ed7aee6fc2593d0f4c1d to your computer and use it in GitHub Desktop.
Save scrwtp/6f60cc6ed422ed7aee6fc2593d0f4c1d to your computer and use it in GitHub Desktop.
namespace SO44893428
module Generic =
let nextId =
let mutable i = 0
let help (key:obj) =
i <- i + 1
i
help
let a = nextId "a" // returns 1
let b = nextId "b" // returns 1
module Concrete =
let nextId : obj -> int =
let mutable i = 0
let help (key:obj) =
i <- i + 1
i
help
let a = nextId "a" // returns 1
let b = nextId "b" // returns 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment