Support optionally printing parameter names
See original GitHub issueIt’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:
- Created 6 years ago
- Reactions:34
- Comments:7 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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?
yup, IMHO for
scala 2.13
productElementNames should yield a pretty neat and simple solution.here my current
pprint
customization forscala 2.11+
by adding additional handlers to pprint, e.g.:for:
it prints:
for code, see https://stackoverflow.com/a/57080463/1276782
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.