mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
doc: remove trailing spaces
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cfdd8cda26
commit
1a65cef0f0
7 changed files with 21 additions and 21 deletions
|
@ -109,22 +109,22 @@ operator with an <code>@</code> as in <code>+@</code> or <code>!@</code>:
|
|||
|
||||
Unary methods accept zero arguments.
|
||||
|
||||
Additionally, methods for element reference and assignment may be defined:
|
||||
<code>[]</code> and <code>[]=</code> respectively. Both can take one or more
|
||||
Additionally, methods for element reference and assignment may be defined:
|
||||
<code>[]</code> and <code>[]=</code> respectively. Both can take one or more
|
||||
arguments, and element reference can take none.
|
||||
|
||||
class C
|
||||
def [](a, b)
|
||||
puts a + b
|
||||
end
|
||||
|
||||
|
||||
def []=(a, b, c)
|
||||
puts a * b + c
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
obj = C.new
|
||||
|
||||
|
||||
obj[2, 3] # prints "5"
|
||||
obj[2, 3] = 4 # prints "10"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue