1

Jokes aside, I have a strange situation, I have some code:

def remotes(form,remotes)
  personalised_form = form.dup
  remotes.each do |ident,remote|
    object = yield(ident)
    result = remote.call(object)
    insert_into_(personalised_form,ident,result)
  end
  personalised_form
end

And I'm seeing if it works like so:

pp remotes(forms,remotes) do |ident|
  case(ident)
    when :get_assets
      '@Userobject'
  end
end

The problem is that ruby seems to think I'm not passing a block to the remotes function.

Why is ruby insisting that I'm not passing a block? (it gives a no block given (yield) (LocalJumpError) specifically).

Thought it's not relevant, remotes is a hash containing key's and Procs, and form is just a specificly structured hash that has the result of the proc inserted into it using the ident to locate the correct insertion point

Thermatix
  • 2,757
  • 21
  • 51

1 Answers1

5

Ruby thinks you are passing the block to pp method, which simply ignores it. Try:

res = remotes(forms,remotes) do |ident|
  case(ident)
    when :get_assets
      '@Userobject'
  end
end

pp res
Borsunho
  • 1,127
  • 7
  • 21
  • hmmm I see, that did indeed fix the issue, I guess I should have put a parenthesis around the remotes function call; I guess it was a precedence issue, more tired then I thought :P, thanks. – Thermatix Oct 21 '15 at 12:34