Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support optionally printing parameter names

See original GitHub issue

Issue Description

It’d be awesome if pprint also supported rendering of parameter names.

E.g., an instance of type

case class Color(red: Byte, green: Byte, blue: Byte)

could be rendered as

Color(red = 10, green = 20, blue = 30)

instead of

Color(10, 20, 30)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:34
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

SethTisuecommented, Sep 25, 2018

scala/scala#6972 was merged (and included in Scala 2.13.0-M5), so maybe there’s hope for this now on Scala 2.13?

vidmacommented, Jul 18, 2019

yup, IMHO for scala 2.13 productElementNames should yield a pretty neat and simple solution.

here my current pprint customization for scala 2.11+ by adding additional handlers to pprint, e.g.:


  pprint2 = pprint.copy(additionalHandlers = pprintAdditionalHandlers)

  case class Author(firstName: String, lastName: String)
  case class Book(isbn: String, author: Author)
  val b = Book("978-0486282114", Author("first", "last"))

it prints: Screenshot 2019-07-18 at 09 38 41

for code, see

for scala 2.11 currently I use plain java reflection to get all class fields & check if a field value exists inside case class (i.e. product.productIterator.toSet.contains(value) ) - yes slightly hacky, but simple and works well, at least in a non-prod environment for tests/info.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to denote that a command line argument is optional ...
Is there a generally accepted way to denote that arg1 and arg2 aren't mandatory arguments when printing the correct usage of the command?...
Read more >
Optionally named parameters · Issue #831 · dart-lang/language
This issue is a proposal to add support for parameters that may be passed as positional and also as named parameters.
Read more >
Specify Parameters - SQL Server | Microsoft Learn
A parameter is considered optional if the parameter has a default value specified when it is declared. It is not necessary to provide...
Read more >
Named And Optional Parameters In C# - C# Corner
This article explains Named and Optional Parameters in C#, their usages and benefits, and how to pass optional parameters in C#.
Read more >
Using Python Optional Arguments When Defining Functions
Defining Functions With No Input Parameters. In this tutorial, you'll use the example of a basic program that creates and maintains a shopping...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found