如果我使用以下groovy代码:
description: '''Join the Perl programmers of the Pork Producers of America as we hone our skills and ham it up a bit. You can show off your programming chops while trying to win a year's supply of pork chops in our programming challenge. Come and join us in historic (and aromatic),Austin,Minnesota. You'll kNow when you're there!'''
是不是groovy应该创建一个只有行之间的单个空格的长字符串(意味着不保留行之间的空格)?结果字符串将是:
加入美国猪肉生产商的Perl程序员,因为我们磨练我们的技能并加以改进……等等
我得到的字符串包含行之间的所有空格.这是预期的行为吗?
解决方法
从Groovy 1.7.3开始:
def description = '''\ Join the Perl programmers of the Pork Producers of America as we hone our skills and ham it up a bit. You can show off your programming chops while trying to win a year's supply of pork chops in our programming challenge. Come and join us in historic (and aromatic),Minnesota. You'll kNow when you're there!'''.stripIndent()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。