Project

General

Profile

Actions

Feature #5196

closed

true should be True.

Added by Tomoki_Imai (Tomoki Imai ) over 12 years ago. Updated about 12 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:38986]

Description

Hello.I'm Tomoki Imai.

I found Ruby has inconsistency.

true is constant value.
In irb,

true = nil
(irb):5: Can't assign to true
true = nil
^
from (irb):5
from :0

We can't change value true.

In Ruby,we use capitalized name for constant value.
For example,
A = 3 .

This is why true should be True.

Updated by steveklabnik (Steve Klabnik) over 12 years ago

In Ruby, you can update constants, though:

ruby-1.9.2-p180 :001 > A = 5
 => 5 
ruby-1.9.2-p180 :002 > A = 6
(irb):2: warning: already initialized constant A
 => 6 

So I don't see how this would change anything.

Updated by drbrain (Eric Hodel) over 12 years ago

There are the constants TRUE, FALSE and NIL which contain true, false and nil

Updated by rkh (Konstantin Haase) over 12 years ago

But constant doesn't mean you can't change it in Ruby... keywords are basically the only thing you can't change. And most of those are not capitalized.
true is a literal, just like nil or 250. You can't change those either.

Ease of use and conventions always outweigh consistency and simplicity in Ruby.

Konstantin

On Aug 16, 2011, at 19:28 , Tomoki Imai wrote:

Issue #5196 has been reported by Tomoki Imai .


Bug #5196: true should be True.
http://redmine.ruby-lang.org/issues/5196

Author: Tomoki Imai
Status: Open
Priority: Normal
Assignee:
Category: core
Target version:
ruby -v: ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

Hello.I'm Tomoki Imai.

I found Ruby has inconsistency.

true is constant value.
In irb,

true

Updated by Tomoki_Imai (Tomoki Imai ) over 12 years ago

Thank you for informations.

But why there is TRUE?

irb(main):007:0> TRUE = false
(irb):7: warning: already initialized constant TRUE
=> false
TRUE can be update.
So,There is no reasons why I use TRUE.

And,I think,there is no reasons why true is not True.
With capitalized True,we can manifest "You can't update True!"

Actions #5

Updated by naruse (Yui NARUSE) over 12 years ago

  • Tracker changed from Bug to Feature

Updated by naruse (Yui NARUSE) over 12 years ago

"true" is not constant but keyword like false, nil, if, else, FILE, LINE, and so on.

Updated by nobu (Nobuyoshi Nakada) over 12 years ago

In common, all uppercase names are used for constants, except for classes and modules.
So True doesn't seem like an ordinary constant, and it doesn't feel nice for me.

Why there is TRUE is the historical reason.
In very early ruby, there wasn't the keyword "true", but only the constant "TRUE".

Updated by mame (Yusuke Endoh) about 12 years ago

  • Status changed from Open to Rejected

I believe this is hopeless.

--
Yusuke Endoh

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0