Wednesday, April 5, 2017

Elixir - bind the match subject in case statement


Before I forget again on how to bind the whole match subject in case statement in Elixir:



"state" as fn argument name and "state" in case surely are having the different scope, that's just I wanted to have the same name saying "state" :).

Reading now "Functional Web Development with Elixir, OTP, and Phoenix", so this is my version of authors to_string:

def​ to_string(coordinate) ​do​
 ​"​​(in_island:​​#{​island(coordinate)​}​​, guessed:​​#{​guessed?(coordinate)​}​​)"​
​end​

I thought I'd write it in a way that I would not call the wrapping functions on Agent for each interpolated field, plus would avoid changing to_string implementation with every struct change.

By the way, new cool link for learning Elixir:


Also, just in time for reading the book mentioned above comes an article from Saša Jurić:
To spawn, or not to spawn? Definitely going to validate the book suggested solution/architecture with what Saša Jurić is writing.
Done with learning for today, back to creating some added value to my customers!

No comments: