# Proc in ruby 1.8.6 and 1.8.7

**URL:** <https://www.ruby-forum.com/t/proc-in-ruby-1-8-6-and-1-8-7/169347>\
**Category:** Ruby\
**Created:** [June 2, 2009, 6:38pm UTC](https://www.ruby-forum.com/t/proc-in-ruby-1-8-6-and-1-8-7/169347 "2009-06-02T18:38:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![robertpostill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8797f3/32.png) [@robertpostill](https://www.ruby-forum.com/u/robertpostill)\
**Post date:** [June 2, 2009, 6:38pm UTC](https://www.ruby-forum.com/t/proc-in-ruby-1-8-6-and-1-8-7/169347/1 "2009-06-02T18:38:24Z")

</div>

In Ruby 1.8.7 it is possible to do such thing:

pr = Proc.new do |arg, &block|  
block.call  
end

pr.call(123) do puts “xyz” end  
xyz  
=\> nil

When calling proc another block can be given as parameter.

Is there any way to do it in Ruby 1.8.6 ?

Not working:

irb(main):001:0\> aba = Proc.new do |arg, &block|  
irb(main):002:1\* end  
SyntaxError: compile error  
(irb):1: syntax error, unexpected tAMPER, expecting ‘|’  
aba = Proc.new do |arg, &block|  
^  
from (irb):2

==

Not working:

irb(main):003:0\> pr = Proc.new do |arg, block|  
irb(main):004:1\* block.call  
irb(main):005:1\> end  
=\> #Proc:0xb7d2d630@:3(irb)  
irb(main):006:0\> pr.call(123) do puts “xyz” end  
NoMethodError: undefined method `call' for nil:NilClass from (irb):4 from (irb):6:in`call’  
from (irb):6  
irb(main):007:0\>

==

Working, but i want to avoid this solution:

irb(main):007:0\> pr.call 123, Proc.new{puts “xyz”}  
xyz  
=\> nil  
irb(main):008:0\>

I hope you people know some cool workaround.

My application is currently running on Ruby 1.8.7 but i would like to  
use REE instead and right now this is the only issue that stops me from  
it.

---

<div class="post-metadata">

**Author:** ![robertpostill](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8797f3/32.png) [@robertpostill](https://www.ruby-forum.com/u/robertpostill)\
**Post date:** [June 2, 2009, 7:13pm UTC](https://www.ruby-forum.com/t/proc-in-ruby-1-8-6-and-1-8-7/169347/2 "2009-06-02T19:13:10Z")

</div>

Robert Pankowecki wrote:

> Working, but i want to avoid this solution:
> 
> irb(main):007:0\> pr.call 123, Proc.new{puts “xyz”}

Yes, that’s what you need - to pass the block as an explicit argument.
