mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Clarify return value for assignment methods.
https://github.com/ruby/ruby/pull/1682 Patch by @sos4nt [fix GH-1682] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2476bf2bb1
commit
86f1d9b705
1 changed files with 5 additions and 1 deletions
|
@ -147,7 +147,7 @@ evaluated.
|
|||
1 + 1 # this expression is never evaluated
|
||||
end
|
||||
|
||||
Note that for assignment methods the return value will always be ignored.
|
||||
Note that for assignment methods the return value will be ignored when using the assignment syntax.
|
||||
Instead, the argument will be returned:
|
||||
|
||||
def a=(value)
|
||||
|
@ -156,6 +156,10 @@ Instead, the argument will be returned:
|
|||
|
||||
p(a = 5) # prints 5
|
||||
|
||||
The actual return value will be returned when invoking the method directly:
|
||||
|
||||
p send(:a=, 5) # prints 6
|
||||
|
||||
== Scope
|
||||
|
||||
The standard syntax to define a method:
|
||||
|
|
Loading…
Add table
Reference in a new issue