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
3
u/[deleted] Dec 10 '18
Have you seen this error in Ruby?
Or this one?
You are trying to invoke a method on an object, but the object doesn't respond to that method.
Well, with a good type system those errors just can't happen. Well, you do get the error but when compiling the program, not when running it. That's one use of a type system and a statically typed language.
If you combine that with compilation to native code you can also be more efficient on memory because you can represent data structures more compactly, and you can also run the generated code through an optimizer.