x = []
x = [42] = 'Foobar'
-error
x = {}
x[42] = 'Foobar'
x
{42 : 'Foobar'}
When we try to assign a value to position 42 in a list it returns an error because items 0-41 dont exist. Because a dictionary relies on mapping rather than sequencing, the key can be created.
Thursday, 24 March 2011
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment