Created
August 18, 2023 07:29
-
-
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
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 : 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