5 ms·
http://code.google.com/p/gtranslate-api-php/ http://code.google.com/p/gtranslate-api-php/ $gt = new Gtranslate; echo "Translating [Ciao mondo] Italian to Engli
by nowarninglabel 16y ago
http://code.google.com/p/gtranslate-api-php/ http://code.google.com/p/gtranslate-api-php/
$gt = new Gtranslate;
echo "Translating [Ciao mondo] Italian to English => ".$gt->it_to_en("Ciao mondo");
- Tomek_ 16y agoBut still not as elegant as: echo "Ciao mondo"->it_to_en(); would be.
- viraptor 16y agoIt's only elegant until you have two libraries which want to add `foo` to a `Bar`. Then you're in the world of pain compared to writing `lib1->foo($myBar);`
- steveklabnik 16y agoI'd rather have the common case be gorgeous and have the uncommon case require a some workaround, than have every case look like crap.
- Tomek_ 16y agoActually I agree, I'm rather against giving programmers ability to extend native objects at free will, but I'm still for strings being objects in PHP, or even having "everything-is-an-object" approach there.
- rbanffy 16y agoI think your example demonstrates very well why one would yearn for Ruby. The ability to give an extra method to a base class allows you to build very expressive code. edit: and, BTW, the to_spanish method is not defined in the https://github.com/jimmycuadra/to_lang/blob/master/lib/to_lang/string_methods.rb https://github.com/jimmycuadra/to_lang/blob/master/lib/to_la... module.
- arethuza 16y agoEven boring old C# can do that.
- ryanpetrich 16y agoNot true. That's just a compiler trick
- troels 16y agoYou're quite right, but in all fairness, the following would be a saner interface in php: italian_to_spanish("Ciao mondo");
- dholowiski 16y agoThank you for proving my point.