Project

General

Profile

Actions

Bug #7782

closed

Struct both has and does not have an allocator

Added by trans (Thomas Sawyer) about 11 years ago. Updated about 11 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]
Backport:
[ruby-core:51846]

Description

=begin
One the one hand:

>> Struct.allocate
TypeError: allocator undefined for Struct
    from (irb):1:in `allocate'
    from (irb):1
    from /opt/Ruby/1.9.3-p327/bin/irb:12:in `<main>'

But on the other:

>> Struct.method(:allocate)
=> #<Method: Class#allocate>

In my current case, I need a reliable way to check if a class can be allocated or not. How can one do this if the method is remains present even when it can not be used?
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0