微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Perl的标量逗号运算符何时有用?

有没有理由在for循环之外的任何地方使用标量逗号运算符?

解决方法

由于Perl标量逗号是C逗号运算符的“端口”,因此 these comments可能是适用的:

Once in a while,you find yourself in
a situation in which C expects a
single expression,but you have two
things you want to say. The most
common (and in fact the only common)
example is in a for loop,specifically
the first and third controlling
expressions. What if (for example) you
want to have a loop in which i counts
up from 0 to 10 at the same time that
j is counting down from 10 to 0?

因此,我认为,你对for循环主要有用的本能是一个很好的直觉.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐