Feature #5196
closed
Added by Tomoki_Imai (Tomoki Imai ) over 12 years ago.
Updated almost 12 years ago.
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.
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.
There are the constants TRUE, FALSE and NIL which contain true, false and nil
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
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!"
- Tracker changed from Bug to Feature
"true" is not constant but keyword like false, nil, if, else, FILE, LINE, and so on.
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".
- Status changed from Open to Rejected
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0Like0