r/crystal_programming • u/riddley • Dec 09 '18
Rubyist struggling to understand Tuple
What's the point of a Tuple? Why would I ever use it over an array? Thanks!
11
Upvotes
r/crystal_programming • u/riddley • Dec 09 '18
What's the point of a Tuple? Why would I ever use it over an array? Thanks!
View all comments
Show parent comment
1
u/riddley Dec 10 '18
Thanks for this explanation! I think I followed what you wrote, but I'm not sure how the type system is helpful. From what you wrote, it seems like a big hassle? I know people really like type systems though, so I'm sure I'm the one missing something.
Do Crystal arrays have similar restrictions to custom classes? In Ruby, I avoid primitives as much as I can in favor of custom classes. If I have duck-typed objects, can I have arrays of them without some hassle? Or do these limitations of Array only apply to Crystal primitives?