String concatenation with Groovy
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: What is the best (idiomatic) way to concatenate Strings in Groovy? Option 1: calculateAccountNumber ( bank , branch , checkDigit , account ) { bank + branch + checkDigit + account } Option 2: calculateAccountNumber ( bank , branch , checkDigit , account ) { "$bank$branch$checkDigit$account" } I've founded an interesting point about this topic in the old Groovy website: Things you can do but better leave undone. As in Java, you can concatenate Strings with the "+" symbol. But Java only needs that one of the two items of a "+"