|
|
|
|
|
by kubb
1652 days ago
|
|
There is another way, you can declare option as type Option[T any] *T
nil is None
opt == nil instead of IsNone()
func Some[T any](t T) Option[T] { return &t }
*opt instead of opt.Get()
option.Map(opt, func(x int) double { return double(x) }) for the monadic behavior
I wish there was type inference for function arguments, so that you could write func(x) { return double(x) }. Maybe in a couple of years the Go team could be convinced. |
|