The Crystal Programming Language Forum

What is `select` re concurrency?

The blog post announcing parallelism mentions select as a concurrency statement, and the release notes for 0.33.0 do too.

I’ve tried to find documentation about said select in the reference guide or docs without luck (perhaps I missed it?). Fiber#select seems like a candidate, but has no docs.

Can anyone give a crash course about it?

It’s derived from Go, best bet would be checking out their docs for the moment.

I see! Which would be the equivalent syntax for

select {
case msg1 := <-c1:
    fmt.Println("received", msg1)
case msg2 := <-c2:
    fmt.Println("received", msg2)


Probably something like

when msg1 = ch1.receive
  puts "received #{msg1}"
when msg2 = ch2.receive
  puts "received #{msg2}"
1 Like

We have some documentation material planned to give better visibility to the select, but for now can help to understand the different options.


Yeah with the changes related to timeout I think we can assume the API is stable enough to write the documentation.

@fxn I’ve been thinking about writing this article since I read your post. It’s finally out!

@lbarasti thanks a lot for the post, and also thanks a lot for following up here :heart:.


Thanks for the Gist, it’s very helpful. Many thanks too for the blog post - and thanks also to @lbarasti for the great article.

I was surprised to not see any mention of the select keyword on the Crystal Documentation about concurrency. Perhaps concurrency model is not completely done today ?

In any case, thanks you all for the quality of this wonderful piece of technology which is promising. More and more people here invest their time to try it out.


I created the docs for the language in one date with everything that was known to the language. Later on we kept adding features but I didn’t keep the docs up to date. Other contributors have, but it seems nobody documented select, mainly because since it’s not documented nobody knows how it works, except for waj. So it’s a chicken and egg problem.