Reputation:
I'm looking for evidence of the unary &
's to_proc behaviour in Ruby source code so that I can write about it. Where are the implementations for the native behaviours of these ruby operators kept? I looked in parse.y and have no idea how to search for this as there are thousands of matches for "&". What's the best way to go about finding ruby implementation details for this? Is there documentation for the ruby source code itself?
Upvotes: 0
Views: 178
Reputation: 1677
The Ruby language itself is documented on ruby-lang.org. In particular, there are pages for Ruby's grammar, syntax, and method calling semantics. For the block-ifying behavior of the &
operator, you might find "Proc to Block Conversion" useful.
I'm not sure where the block-ifying behavior of &
is implemented, but it's relatively straightforward:
&
is a Proc
, then blockify itto_proc
on it and blockify that result (failing if to_proc
isn't defined or fails)Upvotes: 1