Add copy helper function to list (#4)

* Add copy helper function to list

* Add list.copy test

Co-authored-by: ‘markhend’ <‘markhend@gmail.com’>
pull/5/head
Mark Henderson 2021-10-13 15:40:14 -05:00 committed by GitHub
parent dcf1e9ba33
commit fa51d0b583
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -328,6 +328,9 @@ class List:
self[j] = x
i += 1
def copy(self):
return self.__copy__()
# Internal helpers
def _idx_check(self, idx: int, msg: str):

View File

@ -115,6 +115,9 @@ def test_list():
l6.extend(['xyz'])
l6.extend('')
assert l6 == ['a', 'b', 'c', 'xyz']
assert List[int]().copy() == List[int]()
assert [1,2,3].copy() == [1,2,3]
test_list()
@test