-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Describe the feature
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.
Example possible Scala code:
val channel = Channel.make[Int]
select(
channel.recver { n =>
println(s"Received $n")
},
channel.sender(10) {
println("Sent 10")
},
channel.default {
println("Default reached")
}
)
Metadata
Metadata
Assignees
Labels
No labels