6 ms·
PHP also has a nice thing I wish more languages had, which stops you shooting yourself in the foot due to this - the concatentaion operator (.) is different fro
by llimos 5y ago
PHP also has a nice thing I wish more languages had, which stops you shooting yourself in the foot due to this - the concatentaion operator (.) is different from addition (+).
So "5" + 1 is 6, just as 5 + 1 is 6.
- perl4ever 5y agoI can't think offhand of a language that does overload + for strings by default. Perl uses . Oracle SQL uses || Microsoft SQL and VBA use & C obviously doesn't use +. Neither does Pascal. Power Query doesn't.
- Zababa 5y agoJavaScript, Python, Ruby, Go all use +.
- Frondo 5y agoC# does, as do quite a few others. Heh, this is kind of interesting: https://www.rosettacode.org/wiki/String_concatenation https://www.rosettacode.org/wiki/String_concatenation
- rspeele 5y agoC#, GoLang, Javascript, Python, and Ruby are several. Python and Ruby even overload *, for the dubiously useful construction: "hello" * 3 == "hellohellohello"
- infogulch 5y agoI like Julia's standard string concat which subverts a Python user's intuition: "string1" * "string2" == "string1string2". Why? Because monad.
- dahfizz 5y agoJava and Python, from the top of my head, allow "str1" + "str2"
- poizan42 5y ago> Microsoft SQL and VBA use & Nope, Microsoft SQL uses +. * https://docs.microsoft.com/en-us/sql/t-sql/language-elements/string-concatenation-transact-sql?view=sql-server-ver15 https://docs.microsoft.com/en-us/sql/t-sql/language-elements... * https://i.imgur.com/7z81o8t.png https://i.imgur.com/7z81o8t.png * https://i.imgur.com/VDR9qer.png https://i.imgur.com/VDR9qer.png > C obviously doesn't use +. But C++ does for std::string. > Neither does Pascal. Original Pascal didn't, but I think most modern Pascals do (e.g. Object Pascal known from Delphi).
- perl4ever 5y ago>Nope, Microsoft SQL uses +. I was referring to Access. >Original Pascal didn't, but I think most modern Pascals do I'm pretty sure concat() was used in THINK and Metrowerks Pascal in the 90s.
- int_19h 5y agoPascal does, at least in all the more common dialects. VBA (and VB in general) overloads "+" for strings in addition to providing "&", the difference being mostly in what gets converted to what in various situations: https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/plus-operator#remarks https://docs.microsoft.com/en-us/office/vba/language/referen...
- coding123 5y agoThe reason other languages don't have that is very few languages will implicitly convert that "5" to a number. Instead other languages generally only have the implicit convert to string as it's considered less magical.