Skip to content

Commit dc3bdf7

Browse files
committed
Add docs to Binding#numbered_parameters, etc.
1 parent 604d662 commit dc3bdf7

File tree

1 file changed

+47
-3
lines changed

1 file changed

+47
-3
lines changed

proc.c

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,21 @@ bind_local_variable_defined_p(VALUE bindval, VALUE sym)
660660
* call-seq:
661661
* binding.implicit_parameters -> Array
662662
*
663-
* TODO
663+
* Returns the names of numbered parameters and "it" parameter
664+
* that are defined in the binding.
665+
*
666+
* def foo
667+
* [42].each do
668+
* it
669+
* binding.implicit_parameters #=> [:it]
670+
* end
671+
*
672+
* { k: 42 }.each do
673+
* _2
674+
* binding.implicit_parameters #=> [:_1, :_2]
675+
* end
676+
* end
677+
*
664678
*/
665679
static VALUE
666680
bind_implicit_parameters(VALUE bindval)
@@ -683,7 +697,21 @@ bind_implicit_parameters(VALUE bindval)
683697
* call-seq:
684698
* binding.implicit_parameter_get(symbol) -> obj
685699
*
686-
* TODO
700+
* Returns the value of the numbered parameter or "it" parameter.
701+
*
702+
* def foo
703+
* [42].each do
704+
* it
705+
* binding.implicit_parameter_get(:it) #=> 42
706+
* end
707+
*
708+
* { k: 42 }.each do
709+
* _2
710+
* binding.implicit_parameter_get(:_1) #=> :k
711+
* binding.implicit_parameter_get(:_2) #=> 42
712+
* end
713+
* end
714+
*
687715
*/
688716
static VALUE
689717
bind_implicit_parameter_get(VALUE bindval, VALUE sym)
@@ -716,7 +744,23 @@ bind_implicit_parameter_get(VALUE bindval, VALUE sym)
716744
* call-seq:
717745
* binding.implicit_parameter_defined?(symbol) -> obj
718746
*
719-
* TODO
747+
* Returns +true+ if the numbered parameter or "it" parameter exists.
748+
*
749+
* def foo
750+
* [42].each do
751+
* it
752+
* binding.implicit_parameter_defined?(:it) #=> true
753+
* binding.implicit_parameter_defined?(:_1) #=> false
754+
* end
755+
*
756+
* { k: 42 }.each do
757+
* _2
758+
* binding.implicit_parameter_defined?(:_1) #=> true
759+
* binding.implicit_parameter_defined?(:_2) #=> true
760+
* binding.implicit_parameter_defined?(:_3) #=> false
761+
* binding.implicit_parameter_defined?(:it) #=> false
762+
* end
763+
* end
720764
*
721765
*/
722766
static VALUE

0 commit comments

Comments
 (0)