Issue 17 of 30 Days of Hack (HHVM)
A tuple is very similar to a PHP array and a shape. The key feature of tuples is that they are immutable. You may not change the length or the types of the elements in a tuple. The values within the tuple are mutable.
You should use a tuple when you function needs to return more then one value. You do not predefine the types within the tuple but the return annotation of the function has changed. If your function returns a tuple with an integer and a string, then the return type annotation should look like this: (int, string)
Read more at the developer blog.
Tired of waiting for the next lesson?
Read next lesson straight away by upgrading to premium today.Upgrade to premium Sign in
30 Days of Hack (HHVM)
Do you want to learn Facebook’s new programming language Hack? Tobias Nyholm from Happyr will give you an introduction to new features of Hack. This course is for you who know PHP and want to take your coding to the next level. All you have to do is to submit your email and I will send you bits of knowledge every day.Subscribe now