[#74190] [Ruby trunk Feature#12134] Comparison between `true` and `false` — duerst@...
SXNzdWUgIzEyMTM0IGhhcyBiZWVuIHVwZGF0ZWQgYnkgTWFydGluIETDvHJzdC4KCgpUc3V5b3No
3 messages
2016/03/07
[#74269] Type systems for Ruby — Rob Blanco <ml@...>
Dear ruby-core,
5 messages
2016/03/10
[#74395] [Ruby trunk Feature#12142] Hash tables with open addressing — shyouhei@...
Issue #12142 has been updated by Shyouhei Urabe.
3 messages
2016/03/17
[ruby-core:74251] [Ruby trunk Feature#12084] `Class#instance`
From:
justcolin@...
Date:
2016-03-09 21:41:19 UTC
List:
ruby-core #74251
Issue #12084 has been updated by Colin Fulton.
This feature would solve a lot of problems I had while doing what should have been simple meta-programming (if there is such a thing as "simple" meta-programming...).
Something to consider is what happens with nested singleton classes. Let's say you have this code:
```ruby
Array.singleton_class
.singleton_class
.instance
```
Does that return `Array` or the first singleton class? I would think the former is more useful, but less obvious.
----------------------------------------
Feature #12084: `Class#instance`
https://bugs.ruby-lang.org/issues/12084#change-57384
* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee:
----------------------------------------
For meta-programming/debugging purposes, I would like to request the inverse of `Object#singleton_class`. Namely, a method that is called on a class that is a singleton class, and returns the object it is a singleton of. Since the `Singleton` module in the standard library http://ruby-doc.org/stdlib-2.3.0/libdoc/singleton/rdoc/Singleton.html assigns the method name `instance` to such classes, I think `Class#instance` should be the name for such feature.
~~~RUBY
Array.singleton_class.instance # => Array
"foo".singleton_class.instance # => "foo"
~~~
When the receiver is a class but is not a singleton class, then it should raise an error.
~~~RUBY
Array.instance # => error
~~~
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>