From a356fe1c3550892902103f66928426ac8279e072 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 22 Oct 2015 06:30:12 +0000 Subject: Safe navigation operator * compile.c (iseq_peephole_optimize): peephole optimization for branchnil jumps. * compile.c (iseq_compile_each): generate save navigation operator code. * insns.def (branchnil): new opcode to pop the tos and branch if it is nil. * parse.y (NEW_QCALL, call_op, parser_yylex): parse token '.?'. [Feature #11537] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- doc/syntax/calling_methods.rdoc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'doc') diff --git a/doc/syntax/calling_methods.rdoc b/doc/syntax/calling_methods.rdoc index 9cec4526b8..db0217cfef 100644 --- a/doc/syntax/calling_methods.rdoc +++ b/doc/syntax/calling_methods.rdoc @@ -27,6 +27,10 @@ This sends the +my_method+ message to +my_object+. Any object can be a receiver but depending on the method's visibility sending a message may raise a NoMethodError. +You may use .? to designate a receiver, then +my_method+ is not +invoked and the result is +nil+ when the receiver is +nil+. In that case, the +argument of +my_method+ are not evaluated. + You may also use :: to designate a receiver, but this is rarely used due to the potential for confusion with :: for namespaces. -- cgit v1.2.3