Skip to content

Commit 5a1b477

Browse files
committed
Add documentation
1 parent f036dc5 commit 5a1b477

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/docs/reference/metaprogramming/inline.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,25 @@ constant expressions in the sense defined by the [SLS §
228228
including _platform-specific_ extensions such as constant folding of pure
229229
numeric computations.
230230

231+
An inline value must have a literal type such as `1` or `true`.
232+
```scala
233+
inline val four = 4
234+
// equivalent to
235+
inline val four: 4 = 4
236+
```
237+
238+
It is also possible to have inline vals with primitives that do not have a syntactical version such as `Short`.
239+
240+
```scala
241+
trait InlineConstants {
242+
inline val myShort: Short
243+
}
244+
245+
object Constants extends InlineConstants {
246+
inline val myShort/*: Short(4)*/ = 4
247+
}
248+
```
249+
231250
## Transparent Inline Methods
232251

233252
Inline methods can additionally be declared `transparent`.

0 commit comments

Comments
 (0)