/* */

Thursday, 24 March 2011

Tuples - Intro

Tuples are immutable sequences and are created simply by separating value with commas;
1,2,3, you have a tuple!
Usually you'd enclose the tuple in parenthesis:
x = 1,2,3
x
(1,2,3)
() → creates an empty tuple
42, → creates a tuple with 1 value (42,). The added comma specifies its a tuple
note the difference a comma can make:
3x(40+2)
126
3x(40+2,)
(42,42,42)

No comments:

Post a Comment