mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Document Proc#==
This commit is contained in:
parent
861dbd9506
commit
816bbfdc87
Notes:
git
2020-12-22 09:23:04 +09:00
1 changed files with 26 additions and 0 deletions
26
proc.c
26
proc.c
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue