Questions tagged [proc-object]

47 questions
0
votes
1 answer

ArgumentError calling a Proc

s = Proc.new {|x|x*2} puts s.call(5) -> 10 def foo(&a) a.call(5) end puts "test foo:" foo(s) When I try to call the proc above, I get: foo: wrong number of arguments (1 for 0) (ArgumentError) My expectation was that I can pass a proc to a…
uzo
  • 2,821
  • 2
  • 25
  • 26
0
votes
1 answer

Why does this code produce a nil following a Proc.call?

C:\>irb irb(main):001:0> s = Proc.new { puts "Hello" } => # irb(main):002:0> s.call Hello => nil What causes the nil? ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]
uzo
  • 2,821
  • 2
  • 25
  • 26
1 2 3
4