Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
DataSecs9377y@irene What exactly do you mean, why is the string concatenation (in this case implicit conversion) garbage? :o
It's just a nice trick to "abuse" the interpretation strategy of Java :D
In my opinion especially in Java implicit conversion is an awesome thing. Especially widening and autoboxing, that's something really helpful :D I think it's a good fact, that the compiler partly takes care of a thing like that. It usually means that the code is enhanced in efficiency when compiled which to me is a big advantage -
DataSecs9377y@irene It's just a mathematical approach they took for this interpretation strategy.
Because if you but brackets around "somethingElse" it's interpreted before concatenation.
Basically it's relying on a rule similar to "multiply before you add", just in Java.
I think it's quite convenient, what would you suggest as strategy? :o -
DataSecs9377y@irene That would mean more work as a programmer and more stuff to care about. It's a little similar to handling memory on your own. In Java you actually can't but it's a similar idea. You can handle conversion on your own in Java by stopping the implicit conversion with you doing explicit conversion or adopting to the hierarchy its based on. Same with memory in some languages, you can handle it on your own or just let the compiler do it (in this case gbc, because you can't do it yourself). But it's still a 2 way thing, you can prevent it if you want.
-
DataSecs9377y@underscores are brackets around a statement after a string not an easy enough solution? 😂
-
DataSecs9377y@irene Imagine you would have to take care of all the conversions by yourself, how much code that would be. It would make work with Strings very complicated 😅
And just to be sure, do you mean explicit conversion for Strings and other stuff only or for everything else too, like numbers etc? -
Crazed20507y@irene I can't really think of a case where a person would need to add a string and an integer without intending for the integer to be displayed as a string. If you want to output string+int+int, you should really use string+(int+int). It's just more clear that way, and implicit coercion isn't an issue with that :P
-
@qwert sorry, i was busy looking up small indian towns on google maps and listening to kshmr
@irene yeah it annoying but when are you gonna use sysout instead of a logger in prod code eh? -
DataSecs9377y@irene In that particular case I can absolutely understand you. I was rather thinking of different scenarios. It seems to me that it depends a bit of the use-case
Related Rants
When such people exist 🤷♂️ Wish I can undo what I saw 🙈 My day is already ruined 🤦♂️
joke/meme
maths
java
logic