diff options
author | zverok <[email protected]> | 2020-12-21 23:15:47 +0200 |
---|---|---|
committer | Marc-André Lafortune <[email protected]> | 2020-12-21 19:22:38 -0500 |
commit | 816bbfdc87d4a5f600f28cf4b0eaa5161af80645 (patch) | |
tree | e0bde42db3cf2f0c53510efb5488d38d16950d37 /proc.c | |
parent | 861dbd950684d311e4f4bfed0e14885ed8a90b53 (diff) |
Document Proc#==
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3966
Diffstat (limited to 'proc.c')
-rw-r--r-- | proc.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -1273,6 +1273,32 @@ rb_proc_get_iseq(VALUE self, int *is_proc) return NULL; } +/* call-seq: + * prc == other -> true or false + * prc.eql?(other) -> true or false + * + * Two proc are the same if, and only if, they were created from the same code block. + * + * def return_block(&block) + * block + * end + * + * def pass_block_twice(&block) + * [return_block(&block), return_block(&block)] + * end + * + * block1, block2 = pass_block_twice { puts 'test' } + * # Blocks might be instantiated into Proc's lazily, so they may, or may not, + * # be the same object. + * # But they are produced from the same code block, so they are equal + * block1 == block2 + * #=> true + * + * # Another Proc will never be equal, even if the code is the "same" + * block1 == proc { puts 'test' } + * #=> false + * + */ static VALUE proc_eq(VALUE self, VALUE other) { |