Hello everyone, That is an interesting example (actually I was not aware that groovy does that)
Am 24.11.2019 um 01:28 schrieb Simon Sadedin <ssade...@gmail.com>: > Chiming in late here, but the only one I would passionately argue about is > the string <=> numeric conversions. The implicit conversions to / from String > already in Groovy have been responsible for a large proportion of the > impactful bugs that have come out of my complex groovy code. For example, the > fact that this code both compiles and passes the assertion: > > @CompileStatic > class Foo { > String bar() { > return 3 > } > } > assert new Foo().bar() == "3" > > I guess removing this implicit conversion would break things, but I > personally would gladly take the hit in transitioning to Groovy 3.x :-) > > Cheers, > > Simon JavaScrip haters are hating it because of the implicit conversions between strings and numbers/bools (I don’t remember the details, there seem to by many odd cases). In the above example, one could agree that it is still ok, as a literal is converted. And it is basically just one line away from the return type declaration, however if the literal was a variable of static type int, I would not agree that it is automatically converted. Then again on the other hand, the literal is a java.lang.BigInteger, right? And the compiler most likely simply calls .toString() … We have to strive for consistency … it is early in the morning here and I have jet lag … so not really sure what is consistent at the moment :P Regards, Angelo privat: -------------------- www.oomentor.de -------------------------- Angelo Schneider OOAD/UML Patterns/FrameWorks angelo.schnei...@oomentor.de C++/JAVA Mob: +49 172 9873893