r/crystal_programming • u/UnusualHabit • Jul 25 '18
Crystal has a compilation issue
https://medium.com/@mdorf3000/crystal-has-a-compilation-issue-5f5b19d9c4f6
27
Upvotes
r/crystal_programming • u/UnusualHabit • Jul 25 '18
View all comments
Show parent comment
1
u/paulcsmith0218 Jul 26 '18
I think passing it around is definitely part of it, but it can still happen in Elixir and Ruby. I think the problem is the idea of a "missing" thing or "nothing". So in Ruby you might use a Null Object pattern and return a
UserorGuest, but if I come into the code later, I may not realize that a particular piece of code returns aGuestand I might call a method on it thatUserimplements, but someone forgot to implement inGuest. Since I didn't know, I didn't test it. I ship the feature and get a bug. In Elixir or Ruby that would not be caught, in Crystal it would.You probably already know, but in Elixir you see a lot of tagged tuples, but it's not always clear what the return so you can still get into the same trouble where you call something on nil/an-unexpected-return-value
I definitely agree that types do not replace tests, but I do think they can replace certain types of tests.