Hi there 👋, I'm Gideon. Welcome to my GitHub Profile!
-
Create Tutorials in GoLang
-
Create Tutorials in Ruby
-
Python
def my_function(x: int, y: int) -> int:
return x / y
result = my_function(360, 30)
print(result)
- Go
/*
The "Feature" function creates a goroutine to execute the wrapped function asynchronously,
while the returned function waits for the execution to complete before returning the result.
*/
func Feature(f func(interface{}, error)) func() (interface{}, error) {
var result interface{}
var err error
c := make(chan struct{}, 1)
go func() {
defer close(c)
result, err = f()
}()
return func() (interface{}, error) {
<-c
return result, err
}
}