Log in from a computer to take this course

You'll need to log in from a computer to start Introduction to Algorithms and Linear Data Structures in Swift. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store
Learn

Recall from the conceptual lesson that the peek() method will allow us to view the head of the queue without returning it. Let’s implement this functionality in our Queue struct.

Instructions

1.

Declare a method called peek() that will return a value of optional type, String. You should see an error because you haven’t completed the function yet.

2.

Inside peek(), return the value of the first item in our Queue by directly accessing the head’s data.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?