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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:55:59+00:00 2026-05-15T21:55:59+00:00

When I use scala console, it prints an object in a clear style, e.g.

  • 0

When I use scala console, it prints an object in a clear style, e.g.

scala> val mike = ("mike", 40, "New York")
mike: (java.lang.String, Int, java.lang.String) = (mike,40,New York)

But if I write in a script file, like:

val mike = ("mike", 40, "New York")
println(mike)

It only prints:

(mike,40,New York)

How can I do in script file like the scala console? Is there a method for 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-05-15T21:55:59+00:00Added an answer on May 15, 2026 at 9:55 pm

    You can retrieve the type of a variable with a Manifest:

    scala> def dump[T: Manifest](t: T) =  "%s: %s".format(t, manifest[T])
    dump: [T](t: T)(implicit evidence$1: Manifest[T])String
    
    scala> dump((1, false, "mike"))
    res3: String = (1,false,mike): scala.Tuple3[Int, Boolean, java.lang.String]
    

    If the inferred type T is an abstract type, there must be an implicit Manifest[T] provided, otherwise this won’t compile.

    scala> trait M[A] {
         |    def handle(a: A) = dump(a)
         | }
    <console>:7: error: could not find implicit value for evidence parameter of type
     Manifest[A]
              def handle(a: A) = dump(a)
    

    You could make a version that provides a default for the implicit Manifest[T] parameter in this case:

    scala> def dump2[T](t: T)(implicit mt: Manifest[T] = null) = "%s: %s".format(t,
         |    if (mt == null) "<?>" else mt.toString)
    dump2: [T](t: T)(implicit mt: Manifest[T])String
    
    scala> trait M[A] {
         |    def handle(a: A) = dump2(a)
         | }
    defined trait M
    
    scala> (new M[String] {}).handle("x")
    res4: String = x: <?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to use colours in console output in Scala or Java?
What use is the division operator on a scala BigDecimal ? val d1 =
I use play2 to create a default scala app: play new test Then: play
I am trying to use the new immutable OptionParser in the Scala scopt 2.0.1
Our company produces a number of Java / Scala libraries for use by our
scala> val alist = List(1,2,3,4,5) alist: List[Int] = List(1, 2, 3, 4, 5) scala>
I'm impressed with Twitter and investigating to use Scala for a new large scale
Is anyone able to use Scala IDE in Eclipse with syntax highlighting showing different
I'm writing a BloomFilter and wanted to use Scala's default MurmurHash3 implementation: scala.util.MurmurHash3. My
I have a class that I would like to use in a scala.collection.mutable.PriorityQueue, but

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.