Safe retrieval from a list

  • 3
  • Locked
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.
You can't complete this task, because you're not signed in.
Comments (4)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Level 18 , Sofia, Bulgaria
20 January 2021, 12:16
I can't understand, what should I do here?
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.
David Lavigne
Level 19 , Lynnwood, United States
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.
Level 41
27 March 2019, 09:44
Thanks. Fixed.