Skip to content

Commit

Permalink
Add another note
Browse files Browse the repository at this point in the history
  • Loading branch information
deusaquilus committed Dec 29, 2023
1 parent ae7b6a5 commit e843be0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

## <img src="https://github.com/deusaquilus/pprint-kotlin/assets/1369480/9026f8ca-479e-442d-966b-0c1f1f887986" width=50% height=50%>



PPrint is able to print this infinite sequence without stack-overflowing or running out of memory
Expand All @@ -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
Expand Down

0 comments on commit e843be0

Please sign in to comment.