Issue #4910 has been updated by matz (Yukihiro Matsumoto).

Status changed from Assigned to Rejected

It can lead to unreadable code.

Matz.


----------------------------------------
Feature #4910: Classes as factories
https://bugs.ruby-lang.org/issues/4910#change-70514

* Author: rklemme (Robert Klemme)
* Status: Rejected
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
I suggest to add these two to class `Class`:

```ruby
class Class
  alias call new

  def to_proc(*args)
    lambda {|*a| new(*args)}
  end
end
```

Then we can use class instances where blocks are needed and can easily use them as factory instances using the general contract of `#call` (see example attached).

---Files--------------------------------
pro.rb (836 Bytes)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>