diff options
Diffstat (limited to 'doc')
-rw-r--r-- | doc/syntax/assignment.rdoc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/doc/syntax/assignment.rdoc b/doc/syntax/assignment.rdoc index c371593fbe..7e586225b9 100644 --- a/doc/syntax/assignment.rdoc +++ b/doc/syntax/assignment.rdoc @@ -86,11 +86,15 @@ code, for example: 42 # pretend this takes a long time end - big_calculation = big_calculation + big_calculation = big_calculation() Now any reference to +big_calculation+ is considered a local variable and will be cached. To call the method, use <code>self.big_calculation</code>. +You can force a method call by using empty argument parentheses as shown above +or by using an explicit receiver like <code>self.</code>. Using an explicit +receiver may raise a NameError if the method's visibility is not public. + Another commonly confusing case is when using a modifier +if+: p a if a = 0.zero? |