Last active
May 25, 2024 10:18
-
-
Save dacr/5e591f10934392aad8a4b3ec9a284e71 to your computer and use it in GitHub Desktop.
scala3 feature examples - using extension methods / published by https://github.com/dacr/code-examples-manager #d956f95d-7271-492d-be99-f0b63d89a79e/b77d3858fff53fb591f9ea04dde5eb14fa58bbc7
This file contains 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 : scala3 feature examples - using extension methods | |
// keywords : scala3, tutorial, @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 : d956f95d-7271-492d-be99-f0b63d89a79e | |
// created-on : 2021-11-15T20:12:08+01:00 | |
// managed-by : https://github.com/dacr/code-examples-manager | |
// run-with : scala-cli $file | |
//> using scala "3.4.2" | |
import java.util.UUID | |
extension (uuid:UUID) | |
def sexy:String = s"UUID#${uuid.toString}" | |
extension [T](xs: List[T]) | |
def cadr = xs.tail.head | |
@main def go() = | |
println(UUID.randomUUID().sexy) | |
println(List(1,2,3).cadr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment