Last active
December 15, 2015 02:39
-
-
Save paddycarver/5188869 to your computer and use it in GitHub Desktop.
Hey, I just met you, and this is crazy, but here's a random number, it may ask you to call me.
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 main | |
import ( | |
"crypto/rand" | |
"fmt" | |
"math/big" | |
) | |
type action func(bool) | |
func callMe(flag bool) { | |
if flag { | |
fmt.Println("Hey, I just met you") | |
fmt.Println("And this is crazy") | |
fmt.Println("But here's my number") | |
fmt.Println("So call me, maybe?") | |
} | |
} | |
func maybe(a action) { | |
bigint, err := rand.Int(rand.Reader, big.NewInt(100)) | |
if err != nil { | |
panic(err) | |
} | |
i := bigint.Int64() | |
a(i % 4 == 0) | |
} | |
func main() { | |
maybe(callMe) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment