title: Have a class inherit Proc in Ruby
body: <p>I have been trying to inherit the <code>Proc</code> class in Ruby. I know there are tons of other ways I could implement my class without actually inheriting <code>Proc</code>, but now I want to know out of curiosity. </p>
  
  <p>I want a class that can be instantiated without a block passed as an argument, but it just won't work (<a href="https://github.com/ruby/ruby/blob/24da2db3e1eab67b6ee7be00d75b73beb273a4c4/proc.c#L585" rel="nofollow">this</a> seems to be the reason). It is clear that you can't instantiate an actual <code>Proc</code> without a block (not even with a <code>proc</code> or <code>lamba</code>):</p>
  
  <pre><code>Proc.new proc {|x| 2 * x } # =&gt; ArgumentError: tried to create Proc object without a block
  Proc.new lambda {|x| 2 * x } # =&gt; ArgumentError: tried to create Proc object without a block
  </code></pre>
  
  <p>I assumed that overriding <code>initialize</code> might just do the trick, but actually even overriding <code>new</code> won't do:</p>
  
  <pre><code>class MyClass &lt; Proc
    def new *args, &amp;block
      super { |x| 2 * x }
    end
  
    def initialize *args, &amp;block
      super { |x| 2 * x }    
    end
  end
  
  MyClass.new { |x| 2 * x } # =&gt; everything is fine
  MyClass.new "hello" # =&gt; ArgumentError: tried to create Proc object without a block
  </code></pre>
  
  <p>Is there any way (from within Ruby) to go around that restriction in <a href="https://github.com/ruby/ruby/blob/24da2db3e1eab67b6ee7be00d75b73beb273a4c4/proc.c#L585" rel="nofollow">proc.c</a>? Or any elegant workaround?</p>