Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active February 3, 2026 20:26
Show Gist options
  • Select an option

  • Save dacr/5e591f10934392aad8a4b3ec9a284e71 to your computer and use it in GitHub Desktop.

Select an option

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/9a60d075c2c7070052709b792eba4f4d146009f3
// summary : scala3 feature examples - using extension methods
// keywords : scala3, tutorial, @testable
// publish : gist
// authors : David Crosson
// license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
// 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