Re: Re: Short syntax for array literals [...]

From: Date: Wed, 28 May 2008 13:13:40 +0000
Subject: Re: Re: Short syntax for array literals [...]
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-37965@lists.php.net to get a copy of this message
2008/5/28 Stan Vassilev | FM <sv_forums@fmethod.com>: > var array = new Array(); -- same as -- var array = []; > var object = new Object(); -- same as -- var object = {}; > > And when people have both of those, guess which one they use in more than > 90% of the cases. > > Regards, > Stan Vassilev I've moved from PHP to JS and I found this confusing. I don't any more, but I was used to saying I wanted an array by using the Array keyword (makes sense - no shortcut - no confusion). I still say Array() and Object() as they explicitly declare my intentions and others that would find [] and {} confusing (at least initially) don't have to struggle with my code. [] is fine for accessing an array. That's very common in many languages. {} was confusing as that is that is used to wrap a function's code. I don't see any real benefit in using $a = [] over $a = array() So, for a userland developer (rather than a core developer) -1. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!"

« previous php.internals (#37965) next »