Last active
June 15, 2024 07:58
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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