加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2020-12-15 21:53:04 所属栏目:大数据 来源:网络整理
导读:在 this answer中,我看到了语法 =gt ;;这是什么意思?它似乎是基于上下文的某种比较,但这是我可以收集的全部内容.部分背景: sub rev_by_date { $b-[9] = $a-[9] }my @sorted_files = sort rev_by_date @files; 解决方法 从 Perldoc开始: Binary “=” retu
在 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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读