The current Scala channels implementation does not have the default block:
channel := make(<-chan int)
for {
v := 10
select {
case channel <- v:
fmt.Println("Sent value:", v)
case n := <- channel:
fmt.Println("Received:", n)
default: // If none are ready currently, we end up here
fmt.Println("Default reached")
}
}
Although the behavior can be simulated using trySelect() (which also supports timeouts), supporting default block can make porting some pieces of GoLang code easier.
Describe the feature
The current Scala channels implementation does not have the default block:
Although the behavior can be simulated using
trySelect()
(which also supports timeouts), supporting default block can make porting some pieces of GoLang code easier.Example possible Scala code: