Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5959197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:39:04+00:00 2026-05-22T18:39:04+00:00

I’m a strong Java developer who has very recently started trying to pick up

  • 0

I’m a strong Java developer who has very recently started trying to pick up Scala in my free time. I’m going through the Scala by Example PDF from scala-lang.org and am confused how the Quick Sort in the very first example works. Here is the code:

object QuickSort extends App {

  def sort(input: Array[Int]): Array[Int] = {
    if(input.length <= 1) input
    else
    {
      val pivot = input(input.length / 2)
      Array.concat(
          sort(input filter (pivot >)),
               input filter (pivot ==),
          sort(input filter (pivot <))
      )
    }
  }

  sort(Array(5, 4, 3, 2, 1)) foreach println
}

My question is not with the syntax or anything, but I am confused with where the filter function comes from. According to the PDF, it says that it comes from the Seq[T] class, and that all Arrays are instances of Seq[T]. That is all fine and dandy and while reading the PDF I was satisfied and a very happy newbie Scala developer. But then I dug a little deeper and started looking at the scaladoc for Array[T] and also the source code for Array[T] and I do not see how the Array[T] class extends or inherits the Seq[T] trait at all. What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:39:05+00:00Added an answer on May 22, 2026 at 6:39 pm

    You are missing implicits. There’s a few questions about implicits on Stack Overflow. On the PDF you are reading, see chapter 15, starting on page 113. On Scaladoc, you’ll see the relevant implicits on the object scala.Predef — just look for implicit methods which take an Array as input parameter and return something else.

    PS: Yikes, it says Array is a Seq! That might have been the case before Scala 2.8, actually, but since then an Array is a Java Array, pure and simple.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am trying to loop through a bunch of documents I have to put
We're building an app, our first using Rails 3, and we're having to build
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.