DevPrep

All topics › Real interview tasks

Implement a weak-reference collection that conforms to Collection

Senior PRO

Task

Write a generic collection that holds objects weakly and still fully conforms to Collection — so for-in, map, filter, count, first etc. all work.

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store