使用T& amp;有什么问题吗? F代替TRUE&错误的? [英] Is there anything wrong with using T & F instead of TRUE & FALSE?

查看:106
本文介绍了使用T& amp;有什么问题吗? F代替TRUE&错误的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到在R中的函数中使用TF而不是TRUEFALSE可以得到相同的结果.当然,TF更简洁,但是,我看到TRUEFALSE的使用频率更高.

I noticed that using T and F instead of TRUE and FALSE in functions in R gives me the same results. Of course, T and F are more concise, yet, I see TRUE and FALSE being used more often.

我想知道两者之间是否有区别?使用TF有什么问题吗?

I was wondering whether there is any difference between the two? Is there anything wrong with using T and F?

推荐答案

TF,但是TRUEFALSE是保留字,不能重新定义. >

T and F can be re-defined, but TRUE and FALSE are reserved words and cannot be re-defined.

> TRUE <- 1L
Error in TRUE <- 1L : invalid (do_set) left-hand side to assignment
> FALSE <- 0L
Error in FALSE <- 0L : invalid (do_set) left-hand side to assignment
> T <- F  # yikes, this would be hard to debug!

就我个人而言,当我交互式使用R时,有时会使用TF,但是我从不在生产代码或程序包中使用它们.

Personally, I sometimes use T and F when I use R interactively, but I never use them in production code or packages.

这篇关于使用T&amp; amp;有什么问题吗? F代替TRUE&amp;错误的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆