From e843be0280e342db8005b34846c1a7de73e8bf04 Mon Sep 17 00:00:00 2001 From: Alexander Ioffe Date: Fri, 29 Dec 2023 16:24:58 -0500 Subject: [PATCH] Add another note --- README.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6e57f55..31d848c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Add the following to your build.gradle.kts: implementation("io.exoquery:pprint-kotlin:1.0.0") ``` -The use the library like this: +Then use the library like this: ```kotlin import io.exoquery.pprint @@ -96,7 +96,9 @@ var i = 0 val p = SequenceHolder(generateSequence { "foo-${i++}" }) println(pprint(p, defaultHeight = 10)) ``` -![Screenshot from 2023-12-29 15-38-47](https://github.com/deusaquilus/pprint-kotlin/assets/1369480/9026f8ca-479e-442d-966b-0c1f1f887986) + +## + PPrint is able to print this infinite sequence without stack-overflowing or running out of memory @@ -117,6 +119,17 @@ val p = Person(Name("Joe", "Bloggs"), 42) println(pprint(p).plainText) ``` +## Removing Field Names + +By default pprint will print the field names of data classes. You can remove these by using `showFieldNames = false`: + +```kotlin +val p = Person(Name("Joe", "Bloggs"), 42) +println(pprint(p, showFieldNames = false)) +``` + +For larger ADTs this dramatically reduces the amount of output and often improves the readability. + ## Extending PPrint TODO