Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active June 15, 2024 07:58
Show Gist options
  • Save dacr/ba26239bbf4e7fd29266543c8348a9fa to your computer and use it in GitHub Desktop.
Save dacr/ba26239bbf4e7fd29266543c8348a9fa to your computer and use it in GitHub Desktop.
com-lihaoyi os-lib basic usage examples / published by https://github.com/dacr/code-examples-manager #8f69aa4e-c71a-4ff7-abab-b19f67d7cf5a/57c9b86633504afe6b3c21e48fc4fe724ecc94db
// summary : com-lihaoyi os-lib basic usage examples
// keywords : scala, lihaoyi, os-lib, @testable
// publish : gist
// authors : David Crosson
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
// id : 8f69aa4e-c71a-4ff7-abab-b19f67d7cf5a
// created-on : 2024-01-06T11:48:22+01:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : scala-cli $file
// ---------------------
//> using scala "3.4.2"
//> using dep "com.lihaoyi::pprint:0.9.0"
// ---------------------
import pprint.{pprintln, tprint}
pprintln(List(1, 2, 3, 4))
pprintln(List(1, 2, 3, 4), width = 4)
def data = LazyList.continually(java.util.UUID.randomUUID()).take(10000)
pprintln(data, height = 5)
enum Gender(val code: Char) {
case Female extends Gender('F')
case Male extends Gender('M')
}
case class Person(
name: String,
gender: Gender,
age: Int
)
pprintln(Person("John Doe", Gender.Male, 42))
pprintln(Person("John Doe", Gender.Male, 42), width = 10)
pprintln(
tprint[Map[java.util.UUID, Person]]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment