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 8988817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:05:57+00:00 2026-06-15T22:05:57+00:00

Try to understand how I can use type in scala: object TypeSample extends App

  • 0

Try to understand how I can use type in scala:

object TypeSample extends App {

  type MyParams = Map[Int, String]

  def showParams(params: MyParams) = {
    params.foreach(x => x match { case (a, b) => println(a + " " + b) })
  }

  //val params = MyParams( 1 -> "one", 2 -> "two")
  val params = Map( 1 -> "one", 2 -> "two")

  showParams(params)

}

This line throws compilation exception: “Can not resolve symbol ‘MyParams'”

//val params = MyParams( 1 -> "one", 2 -> "two")

Why? I can not use ‘type’ like this?

  • 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-06-15T22:05:58+00:00Added an answer on June 15, 2026 at 10:05 pm

    Because MyParams is only an alias to the type Map[Int, String]. To make this work, you have to add a factory like

    object MyParams {
      def apply(params: (Int, String)*) = Map(params: _*)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to understand the regex in python. How can i split the following
Does anybody try zf2? I can not understand new mechanism of using sessions in
I try to parse encrypted &RQ history, but i really can't understand asm code.
I am terrible at Jquery, and can barely understand it as I try to
there is one think, i can't understand anyway:((( when i try to set cookie(it
I can fix the below exception with a try-catch loop but I cannot understand
can someone help me to understand how to use Applicative style for writing Parsec
I am trying to understand how to use functional pointers to map the method
I am having trouble with structure definitions. I understand the syntax but can't use
I can't understand how to use predicate, I have a very long code to

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.