Skip to content

Instantly share code, notes, and snippets.

@dacr
Created August 18, 2023 07:29
Show Gist options
  • Save dacr/c4842a95218ebd21bbdc49fa5b0b3852 to your computer and use it in GitHub Desktop.
Save dacr/c4842a95218ebd21bbdc49fa5b0b3852 to your computer and use it in GitHub Desktop.
scala3 macro examples - basic / published by https://github.com/dacr/code-examples-manager #e6698631-4a91-4982-9c5a-aae0b9f91f25/1f0180a6375c5ff0ee0c50e2e22fa9b65c89078a
// summary : scala3 macro examples - basic
// keywords : scala3, tutorial, macro, @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 : e6698631-4a91-4982-9c5a-aae0b9f91f25
// created-on : 2023-08-10T15:25:31+02:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : scala-cli $file
// Some resources
// https://medium.com/codex/scala-3-macros-without-pain-ce54d116880a
inline val valueEvaluatedAtCompileTime = 42d * math.Pi
println(s"42*PI = $valueEvaluatedAtCompileTime")
inline def upper(inline str: String) = str.toUpperCase
println(s"An uppercase string : ${upper("hello world")}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment