Inline Methods
Scala 3 inline.
What Is inline?
The inline keyword in Scala 3 tells the compiler to expand a definition at the call site during compilation. It is the entry point to metaprogramming, before full macros.
An Inline Method
Mark a method inline and its body is substituted wherever it is called. This can remove call overhead and enable compile-time specialization.
inline def square(x: Int): Int = x * x
val r = square(5) // compiles to 5 * 5All lessons in this course
- Inline Methods
- Macros Basics
- Quotes and Splices
- Practical Macros