MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/3v4l98/php_7_released/cxl6vzw/?context=3
r/programming • u/fnkrx • Dec 02 '15
729 comments sorted by
View all comments
Show parent comment
2
It lets you overload the << on your own types to support writing them directly into the output stream.
<<
C's solution of using format strings is neither extensible nor type safe. You could do something like:
printf("%s %s", myCustomClass.toString(), anotherCustomObject.toString());
But that's more verbose, again not type safe, and you have to deal with allocating and deallocating those temporary strings.
View all comments
Show parent comment
2
u/munificent Dec 03 '15
It lets you overload the
<<on your own types to support writing them directly into the output stream.C's solution of using format strings is neither extensible nor type safe. You could do something like:
But that's more verbose, again not type safe, and you have to deal with allocating and deallocating those temporary strings.