mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
doc/syntax/methods.rdoc: fix a misleading example
As a bonus, wrap a long line added by r60295. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7fa932ece6
commit
171f968d22
1 changed files with 3 additions and 3 deletions
|
@ -147,14 +147,14 @@ evaluated.
|
||||||
1 + 1 # this expression is never evaluated
|
1 + 1 # this expression is never evaluated
|
||||||
end
|
end
|
||||||
|
|
||||||
Note that for assignment methods the return value will be ignored when using the assignment syntax.
|
Note that for assignment methods the return value will be ignored when using
|
||||||
Instead, the argument will be returned:
|
the assignment syntax. Instead, the argument will be returned:
|
||||||
|
|
||||||
def a=(value)
|
def a=(value)
|
||||||
return 1 + value
|
return 1 + value
|
||||||
end
|
end
|
||||||
|
|
||||||
p(a = 5) # prints 5
|
p(self.a = 5) # prints 5
|
||||||
|
|
||||||
The actual return value will be returned when invoking the method directly:
|
The actual return value will be returned when invoking the method directly:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue