Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbol procs as groups don't work as expected. #405

supersam654 opened this issue Apr 12, 2019 · 2 comments


None yet
3 participants
Copy link

commented Apr 12, 2019

Consider these two groups:

Flipper.register(:working) do |actor|

Flipper.register(:broken, &:admin?)

class User
  def admin?

The first group works as expected. However, the second group raises an exception about passing the wrong number of arguments to admin? even though it appears to be syntactic sugar for the first one.

I did some digging and the problem appears to be at

Notably, the arity of the symbol proc is -1 while the arity of the regular block is 1.

def print_arity(&block)
  puts block.arity

print_arity(&:to_s) # Prints -1
print_arity { |a| a.to_s } # Prints 1

With all of that said, I'm not very familiar with arity checking in Ruby. However, it seems that checking the absolute value of the arity would work in this situation. If someone else thinks this is a good idea, I'd be more than happy to make the (tiny) PR for this.


This comment has been minimized.

Copy link

commented Apr 20, 2019

Definitely open to a PR with a spec/fix.


This comment has been minimized.

Copy link

commented May 11, 2019

Closing since this was resolved by #406

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.