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

  • SEARCH
  • Home
  • 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 7052189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:21:14+00:00 2026-05-28T03:21:14+00:00

I’m taking my first interesting steps (non-hello-world level) with Scala (2.9.1) and I’m stuck

  • 0

I’m taking my first interesting steps (non-hello-world level) with Scala (2.9.1) and I’m stuck trying to understand a very uninformative error message.
It goes much like this:

error: type mismatch;
found   : (Int, Array[InputEntry]) => (Int, Double)
required: (Int, Array[InputEntry]) => ?
entries.groupBy(grouper).map((k: Int, ies: Array[InputEntry]) => (k, doMyStuff(ies)))

As you can guess process in this snippet is supposed to be where some processing goes on, and it’s actually a well defined function with signature Array[InputEntry] => Double.

Grouper’s signature, instead, is Array[InputEntry] => Int.

I’ve tried to extract a function and replace the lambda but it was useless, and I’m stuck trying to understand the question mark in the error…

Any ideas?

Edit: I should clarify that InputEntry is a class I’ve defined, but for the sake of this example it seems to me like it’s hardly relevant.

  • 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-28T03:21:14+00:00Added an answer on May 28, 2026 at 3:21 am

    This looks like the problem:

    .map((k: Int, ies: Array[InputEntry]) => (k, doMyStuff(ies)))
    

    You need to use a case statement to unapply the params and assign them to local variables. You also need to use {} instead of () because it is an anonymous function now.

    entries.groupBy(grouper).map{case (k, ies) => (k, doMyStuff(ies))}
    

    Here’s a more simple example.

    scala> val x = List(("a",1),("b",2))
    x: List[(java.lang.String, Int)] = List((a,1), (b,2))
    scala> x.map{ case (str, num) => num }
    res5: List[Int] = List(1, 2)
    

    If you don’t want to use a case statement, you have to keep the tuple as a single variable.

    scala> x.map(tuple => tuple._2)
    res6: List[Int] = List(1, 2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y’all
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
Specifically, suppose I start with the string string =hello \'i am \' me And
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to select an H1 element which is the second-child in its group

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.