0PricingLogin
Scala for Backend Engineering & Functional Programming · Lesson

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 * 5

All lessons in this course

  1. Inline Methods
  2. Macros Basics
  3. Quotes and Splices
  4. Practical Macros
← Back to Scala for Backend Engineering & Functional Programming