Once upon a time there was a list of integers. Everything would have been fine, but it lacked a method to safely retrieve the numbers. Take pity on the list and create such a method for it. It must return a list item based on its index. If an exception occurs while retrieving an element, it must be caught, and the method should return defaultValue.
Safe retrieval from a list
- 3
Locked
Comments (4)
- Popular
- New
- Old
You must be signed in to leave a comment
remote87
20 January 2021, 12:16
I can't understand, what should I do here?
0
John Squirrels Website Admin at CodeGym
21 January 2021, 11:09
Post your question in HELP section and send us a link.
Our devs will gladly assist you.
0
David Lavigne
24 March 2019, 00:23
This way this question is worded is confusing.
It can easily be interpreted as "Remove an item" for the list -> which fails validation
With the way validation is set up, this should be titled and the description updated to say "safe fetching from a list" or something similar.
+1
Roman
27 March 2019, 09:44
Thanks. Fixed.
0