Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Differentiate between block args with defaults and without. #83

Merged
merged 1 commit into from
Jun 19, 2014

Conversation

myronmarston
Copy link
Member


obj = Object.new
obj.define_singleton_method(:to_lambda, &block)
obj.method(:to_lambda).to_proc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to_lambda to_proc? Can you elaborate how this works?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Methods and lambdas share semantics in terms of how return works and how they handle arguments. To convert a proc to a lambda on MRI, we need to define a method using the proc, and then, use Method#to_proc to get back proc that's a lambda proc.

I just chose to_lambda as the name for the method but it doesn't really matter what it's named.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see, so to_proc actually returns a lambda ok, thanks :)

@JonRowe
Copy link
Member

JonRowe commented Jun 19, 2014

I'm curious about how the implementation works but it looks good to me, considering the build passes.

myronmarston added a commit that referenced this pull request Jun 19, 2014
Differentiate between block args with defaults and without.
@myronmarston myronmarston merged commit 82fc76e into master Jun 19, 2014
@myronmarston myronmarston deleted the fix-block-signature branch June 19, 2014 14:32
@JonRowe JonRowe mentioned this pull request Jun 21, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants