gpt4 book ai didi

perl - Perl 的标量逗号运算符什么时候有用?

转载 作者:行者123 更新时间:2023-12-03 01:32:52 25 4
gpt4 key购买 nike

是否有任何理由在 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 循环中有用,这是一个很好的直觉。

关于perl - Perl 的标量逗号运算符什么时候有用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2200759/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com