Go: Using a Closure in Place of a Struct

nwillc
Level Up Coding
Published in
2 min readMar 31, 2021

--

This note isn’t suggesting a pattern to follow, it’s a thought exercise. Let’s look at using a closure where we’d idiomatically use a struct.

A Fibonacci Number Sequence Generator

For this thought exercise, we will implement a Fibonacci Number sequence generator two ways, once with a struct and once with a closure. We’ll use the same approach…

--

--

Graybeard code monkey, started on an Apple IIe, got a CS degree in the 80’s, and coded my way through C, C++, Objective-C, Java, Kotlin — and now Go.