6 ms·
Why would you do this for numbers? How is $number = new Number(6.9); echo $number->ceiling() // 7 ->max(array(5, 9, 49.1)) //
by rorrr2 13y ago
Why would you do this for numbers?
How is
$number = new Number(6.9);
echo $number->ceiling() // 7
->max(array(5, 9, 49.1)) // 49.1
->floor() // 49
->sqrt() // Value
->value(); // Get raw value rather than string
better than writing it in actual functions?
sqrt(
floor(
max(
5, 9, 49.1, ceil(6.9)
)
)
)
- niteshade 13y agoI think its ugly?
- rorrr2 13y agoI think converting numbers to objects and back is ugly. And insanely inefficient. For this particular example it must be orders of magnitude slower.
- niteshade 13y agoWell yeah, efficiency wasn't the aim.
- rorrr2 13y agoOK, if I never need to write insanely slow object oriented code for no good reason, I will download your "library".
- matthewmacleod 13y agoDon't be a dick, dude.
- deleted 13y ago[deleted]
- xd 13y agoIt's as efficient as you can possibly get with PHP .. how is that ugly? Ugly because it doesn't remind you of Python, Ruby or whichever language you prefer?
- niteshade 13y agoYeah, mostly. Also because its how it should have been done. PHP Internals should strive to clean up PHP to conform to my work ;)
- xd 13y agoNothing wrong with that attitude at all! Especially when backed up with code. Keep up the good fight .. but I would suggest you implement this as an extension.
- niteshade 13y agoYeah, I think that'll be the way to go. There's apparently a new way of writing extensions, might've gotten slightly more bearable since you last looked at it :)
- xd 13y agoI've never really understood the incessant need to replicate idioms from other languages on top of the already existing idioms in PHP.
- niteshade 13y agoIncessant? I suppose it is, the language is in real need of it.
- xd 13y agoI've been using PHP for over 12years now. I even attempted what you are doing once, but via an extension, but quickly realised I was simply complicating things in some misguided attempt to fix which wasn't broken.