2 ms·
The key is the `rethrows` keyword, which allows the compiler to conditionally enforce error handling based on the signature of the given closure. The equivalen
by thought_alarm 10y ago
The key is the `rethrows` keyword, which allows the compiler to conditionally enforce error handling based on the signature of the given closure.
The equivalent Go code would then (presumably) be these two methods:
func drop(seq []T, while func(T) (bool)) ([]T)
func dropWithError(seq []T, while func(T) (bool, error)) ([]T, error)
If you pass in a closure that throws (i.e., can return an error) then the compiler will require try/catch error handling at the `drop()` method call site.
If you pass in a closure that does not throw then compiler will assume that `drop()` does not throw.