Get immediate access to this and over 1,500+ other videos and books.

Boost your skills with a Beginner subscription. With over 60+ video courses and our core foundational programming books bundled in one subscription, it’s simply the best investment you can make in your development career.

Challenge: Write a Generic Function

This video was last updated on Jun 21 2022

Now that you understand generics, you’ll put your new knowledge to the test by writing a method that filters a collection of numbers.


Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a Professional subscription.

Now it’s time for the last and final challenge of this course. You just watched two episodes on generics. Now it’s time to put your knowledge to the test.

var scores = [
    [96, 46, 87],
    [87, 78, 80],
    [90, 86, 95],

var interests = [
    ['Video Games', 'Reading', 'Soccer'],
    ['Gymnastics', 'Step Dancing', 'Softball'],
    ['Horseback Riding', 'Hockey', 'Writing']
List<T> flattenList
List<T> flattenList<T>
List<T> flattenList<T>(List<List<T>> list) {

var flatList = <T>[];
for (var item in list) {
    for (var subItem in item) {

return flatList;
// Takes in a list of lists and extracts all items into a single list
var flatScores = flattenList(scores);
var flatInterests = flattenList(interests);