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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:10:20+00:00 2026-05-26T08:10:20+00:00

Is it there an equivalent of Pythons repr function in scala? Ie a function

  • 0

Is it there an equivalent of Pythons repr function in scala?

Ie a function which you can give any scala object an it will produce a string representation of the object which is valid scala code.

eg:

val l = List(Map(1 -> "a"))

print(repr(l))

Would produce

List(Map(1 -> "a"))
  • 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-26T08:10:21+00:00Added an answer on May 26, 2026 at 8:10 am

    There is mostly only the toString method on every object. (Inherited from Java.) This may or may not result in a parseable representation. In most generic cases it probably won’t; there is no real convention for this as there is in Python but some of the collection classes at least try to. (As long as they are not infinite.)

    The point where it breaks down is of course already reached when Strings are involved

    "some string".toString == "some string"
    

    however, for a proper representation, one would need

    repr("some string") == "\"some string\""
    

    As far as I know there is no such thing in Scala. Some of the serialisation libraries might be of some help for this, though.

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

Sidebar

Related Questions

Is there any Ruby equivalent for Python's builtin zip function? If not, what is
Is there equivalent to \Q ... \E in C# Regex? I can't find it.
shutil.rmtree will not delete read-only files on Windows. Is there a python equivalent of
Are there any equivalent JavaScript functions for Python's urllib.parse.quote() and urllib.parse.unquote() ? The closest
Does anybody know if there is a Clojure equivalent for Pythons dir. Basically I
Is there a C# equivalent to Python's id() ? If not, how can I
Is there a Python equivalent for Ruby's define_method , which would allow dynamic generation
Is there any equivalent to KeyedCollection in Python, i.e. a set where the elements
Is there an equivalent python function for each of the following (maybe in the
Is there a java equivalent of the python eval function? This would be a

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.