if (@array) 在 perl 中是什么意思? [英] What does if (@array) mean in perl?
本文介绍了if (@array) 在 perl 中是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这在 Perl 中是什么意思?
What does this mean in Perl?
if (@array)
if (!@array)
这是否意味着我们让 Perl 检查数组是否存在?
Does this mean if we ask Perl to check if array exists or not?
谢谢
推荐答案
标量上下文中的数组返回元素的数量.所以 if(@array)
检查数组是否有任何元素.它类似于 if(scalar(@array)!=0)
.
An array in scalar context returns the number of elements. So the if(@array)
checks if the array has any elements or not. It's similar to if(scalar(@array)!=0)
.
这篇关于if (@array) 在 perl 中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文