Skip to content

Commit

Permalink
Update 2.2.md
Browse files Browse the repository at this point in the history
directly call method getitem() will receive a NameError
we can use x.__getitem__(0) or index grammar x[0]
  • Loading branch information
Xudong authored Jul 17, 2018
1 parent bc68dc3 commit 2379ce5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 2.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ Python 中的元组(以及多数其它编程语言中的序列)下标都以
>>> def make_rat(n, d):
return (n, d)
>>> def numer(x):
return getitem(x, 0)
return x.__getitem__(0)
>>> def denom(x):
return getitem(x, 1)
return x.__getitem__(1)
```

用于打印有理数的函数完成了我们对抽象数据结构的实现。
Expand Down

0 comments on commit 2379ce5

Please sign in to comment.