Created
February 1, 2022 09:54
-
-
Save AntonStoeckl/72c68812972dfa2a1585c6ab7fff7d9b to your computer and use it in GitHub Desktop.
Example for blog post: Go bits: Magic with functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package closures_test | |
import ( | |
"testing" | |
"github.com/matryer/is" | |
. "go-bits/magic-with-functions/closures" | |
) | |
// Build a parametrized function with a closure | |
func Test_isBigger_with_a_closure(t *testing.T) { | |
// Arrange | |
shouldBe := is.New(t) | |
isBiggerThan1 := IsBiggerThan(1) | |
// Act | |
result := isBiggerThan1(2) | |
// Assert | |
shouldBe.True(result) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment