Go has
Go has interfaces, which I don't understand very well, but they can be used to give polymorphic behavior.
Here is a simple, familiar Go program using a goroutine and a channel. Notice that the type declaration comes after the variable name, and the arrow symbol for flow into and out of the channel, c.
package main import "fmt" func fib(c chan int) { var a, b int = 1, 0 for { c <- a a, b = a + b, a } } func main() { c := make(chan int) go fib(c) for i := 1; i < 12; i++ { f := <- c fmt.Println(f) } } |
1 1 2 3 5 8 13 21 34 55 89 |