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

Perl中<=>(小于,等于,大于)的含义?

this answer中,我看到了语法< =&gt ;;这是什么意思?它似乎是基于上下文的某种比较,但这是我可以收集的全部内容.部分背景:
sub rev_by_date { $b->[9] <=> $a->[9] }
my @sorted_files = sort rev_by_date @files;

解决方法

Perldoc开始:

Binary “<=>” returns -1,or 1 depending on whether the left argument is numerically less than,equal to,or greater than the right argument. If your platform supports NaNs (not-a-numbers) as numeric values,using them with “<=>” returns undef. NaN is not “<“,“==”,“>”,“<=” or “>=” anything (even NaN),so those 5 return false. NaN != NaN returns true,as does NaN != anything else. If your platform doesn’t support NaNs then NaN is just a string with numeric value 0.

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

相关推荐