On 26.06.2013, at 17:29, Sebastian Krebs <krebs....@gmail.com> wrote:
> 2013/6/26 Robert Stoll <rst...@tutteli.ch> > >> As far as I see it, it is kind of an operator overload mechanism for the >> assign operator. >> This can be useful for small utility classes such as Money, Email etc. >> >> An example was given: >> $price = new MoneyValue(); >> $price := 29.99; >> >> Instead of writing something like: >> $price = new MoneyValue(); >> $price->setPrice(29.99); >> >> The benefit is small, but can lead to better readable code. But since it >> is only for the assign operator and not for + - etc., for me the question >> remains open why not writing something like this directly: >> >> $price = new MoneyValue(29.99); >> > > You forgot the currency ;) (without it a "money"-type is useless). But this > leads to > > $price := 29.99; > $price := 'USD'; > > I find it confusing. Not to mention, that one should NEVER use float for money http://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency -- Alexey Zakhlestin CTO at Grids.by/you https://github.com/indeyets PGP key: http://indeyets.ru/alexey.zakhlestin.pgp.asc -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php