Monday, August 17, 2009

"FAQ"-ing PHP vs Hi-Level languages

php > $a = array('a','b','c');
php > unset($a[1]);
php > var_dump($a);
array(2) {
[0]=>
string(1) "a"
[2]=>
string(1) "c"
}

Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a = ['a', 'b', 'c']
>>> a
['a', 'b', 'c']
>>> a.pop(1)
'b'
>>> a
['a', 'c']
>>> a[2]
Traceback (most recent call last):
File "", line 1, in
IndexError: list index out of range
>>> a[1]
'c'
>>> a[0]
'a'
>>>

No comments: